Commit b2b1b2fb authored by nanahira's avatar nanahira

chunking archive save

parent 621974e9
Pipeline #12483 passed with stages
in 5 minutes and 45 seconds
...@@ -207,10 +207,9 @@ export class AppService extends ConsoleLogger { ...@@ -207,10 +207,9 @@ export class AppService extends ConsoleLogger {
const result = await this.packager.build(stream, app.packagePrefix, previousTracingBuildChecksums); const result = await this.packager.build(stream, app.packagePrefix, previousTracingBuildChecksums);
this.log(`Saving package info of ${app.id} ${version} for ${JSON.stringify(depot)}`); this.log(`Saving package info of ${app.id} ${version} for ${JSON.stringify(depot)}`);
build.checksum = result.checksum; build.checksum = result.checksum;
build.archives = result.archives; //build.archives = result.archives;
build = await this.db.getRepository(Build).save(build); //build = await this.db.getRepository(Build).save(build);
this.mirror.triggerMirror();
/*
await this.db.transaction(async (edb) => { await this.db.transaction(async (edb) => {
this.log(`Saving build info.`); this.log(`Saving build info.`);
build = await edb.getRepository(Build).save(build); build = await edb.getRepository(Build).save(build);
...@@ -218,7 +217,7 @@ export class AppService extends ConsoleLogger { ...@@ -218,7 +217,7 @@ export class AppService extends ConsoleLogger {
let currentSize = 0; let currentSize = 0;
for (const archive of result.archives) { for (const archive of result.archives) {
archive.build = build; archive.build = build;
const size = archive.paramSize; const size = archive.getParamSize();
if (currentSize > 0 && currentSize + size > 60000) { if (currentSize > 0 && currentSize + size > 60000) {
this.log(`Saving ${archivePot.length} archive infos.`); this.log(`Saving ${archivePot.length} archive infos.`);
await edb.getRepository(Archive).save(archivePot); await edb.getRepository(Archive).save(archivePot);
...@@ -233,7 +232,8 @@ export class AppService extends ConsoleLogger { ...@@ -233,7 +232,8 @@ export class AppService extends ConsoleLogger {
await edb.getRepository(Archive).save(archivePot); await edb.getRepository(Archive).save(archivePot);
} }
}); });
*/
this.mirror.triggerMirror();
this.log(`Finished packaging ${app.id} ${version} for ${JSON.stringify(depot)}`); this.log(`Finished packaging ${app.id} ${version} for ${JSON.stringify(depot)}`);
return new BlankReturnMessageDto(201, 'success'); return new BlankReturnMessageDto(201, 'success');
} catch (e) { } catch (e) {
...@@ -353,9 +353,7 @@ export class AppService extends ConsoleLogger { ...@@ -353,9 +353,7 @@ export class AppService extends ConsoleLogger {
async checkHashFromUrl(url: string) { async checkHashFromUrl(url: string) {
this.log(`Downloading ${url} for checking hash.`); this.log(`Downloading ${url} for checking hash.`);
const { data } = await lastValueFrom( const { data } = await lastValueFrom(this.http.get<internal.Readable>(url, { responseType: 'stream' }));
this.http.get<internal.Readable>(url, { responseType: 'stream' })
);
return new Promise<string>((resolve, reject) => { return new Promise<string>((resolve, reject) => {
const hashObject = createHash('sha256'); const hashObject = createHash('sha256');
data.on('data', (data) => hashObject.update(data)); data.on('data', (data) => hashObject.update(data));
......
...@@ -44,9 +44,9 @@ export class Archive extends TimeBase { ...@@ -44,9 +44,9 @@ export class Archive extends TimeBase {
return `${this.path}.tar.zst`; return `${this.path}.tar.zst`;
} }
//get paramSize() { getParamSize() {
// return 5 + (this.containingFiles ? this.containingFiles.length * 2 : 0); return 5 + (this.files?.length || 0);
//} }
toMetalinkView() { toMetalinkView() {
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment