Commit d0c50744 authored by nanahira's avatar nanahira

chunk database save

parent a783907a
Pipeline #4990 passed with stages
in 3 minutes and 31 seconds
......@@ -190,7 +190,7 @@ export class AppService extends ConsoleLogger {
if (await this.checkExistingBuild(depot, version)) {
throw new BlankReturnMessageDto(404, 'Build exists').toException();
}
const build = new Build();
let build = new Build();
build.depot = depot;
build.version = version;
this.log(`Start packaging ${app.id} ${version} for ${JSON.stringify(depot)}.`);
......@@ -203,8 +203,29 @@ export class AppService extends ConsoleLogger {
const result = await this.packager.build(stream, app.packagePrefix, previousTracingBuildChecksums);
this.log(`Saving package info of ${app.id} ${version} for ${JSON.stringify(depot)}`);
build.checksum = result.checksum;
build.archives = result.archives;
await this.db.getRepository(Build).save(build);
// build.archives = result.archives;
await this.db.transaction(async (edb) => {
this.log(`Saving build info.`);
build = await edb.getRepository(Build).save(build);
let archivePot: Archive[] = [];
let currentSize = 0;
for (const archive of result.archives) {
archive.build = build;
const size = archive.paramSize;
if (currentSize > 0 && currentSize + size > 60000) {
this.log(`Saving ${archivePot.length} archive infos.`);
await edb.getRepository(Archive).save(archivePot);
archivePot = [];
currentSize = 0;
}
archivePot.push(archive);
currentSize += size;
}
if (archivePot.length) {
this.log(`Saving ${archivePot.length} archive infos.`);
await edb.getRepository(Archive).save(archivePot);
}
});
this.log(`Finished packaging ${app.id} ${version} for ${JSON.stringify(depot)}`);
return new BlankReturnMessageDto(201, 'success');
} catch (e) {
......
......@@ -42,6 +42,10 @@ export class Archive extends TimeBase {
return `${this.path}.tar.zst`;
}
get paramSize() {
return 5 + (this.containingFiles ? this.containingFiles.length : 0);
}
toMetalinkView() {
return {
name: this.archiveFullPath,
......
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