Commit 413b50b1 authored by nanahira's avatar nanahira

don't pack any part archives for only 1 part archive

parent d9679841
Pipeline #5386 passed with stages
in 3 minutes and 37 seconds
......@@ -138,6 +138,8 @@ export class PackagerService extends ConsoleLogger {
}
}
const pendingPartTasks: ArchiveTask[] = [];
// 散包
const buckets: Record<string, [FileWithHash[], number]> = {};
for (const file of filesWithHash) {
......@@ -146,7 +148,7 @@ export class PackagerService extends ConsoleLogger {
buckets[extname] ??= [[], 0];
const bucket = buckets[extname];
if (bucket[1] + file.file.stats.size >= this.bucket_max) {
new ArchiveTask(ArchiveType.Part, bucket[0]).addToTask(archiveTasks);
new ArchiveTask(ArchiveType.Part, bucket[0]).addToTask(pendingPartTasks);
bucket[0] = [];
bucket[1] = 0;
} else {
......@@ -154,13 +156,21 @@ export class PackagerService extends ConsoleLogger {
bucket[1] += file.file.stats.size;
}
} else {
new ArchiveTask(ArchiveType.Part, [file]).addToTask(archiveTasks);
new ArchiveTask(ArchiveType.Part, [file]).addToTask(pendingPartTasks);
}
}
for (const bucket of Object.values(buckets)) {
if (bucket[0].length) {
new ArchiveTask(ArchiveType.Part, bucket[0]).addToTask(archiveTasks);
new ArchiveTask(ArchiveType.Part, bucket[0]).addToTask(pendingPartTasks);
}
}
if (pendingPartTasks.length > 1) {
for (const task of pendingPartTasks) {
task.addToTask(pendingPartTasks);
}
} else {
this.log(`Skipping part archives because only 1 part archive.`);
}
const packages = await Promise.all(archiveTasks.map((t) => this.archive(root, t))); // 这个 await 过后,checksum 和 打包上传都已经跑完了
......
......@@ -186,6 +186,9 @@ export class UpdateService extends ConsoleLogger {
}
private pickArchives(archives: Archive[], requestedFiles: string[]) {
if (!archives.length) {
return [];
}
const aset = archives.map((a) => ({ archive: a, files: new Set(a.files) }));
const result = new Set<Archive>();
......
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