core: handle image download cache

This commit is contained in:
undefined committed 2021-08-17 22:21:27 +08:00
1 parent 33b9b0b048
commit d0471b0de8
17 files changed
+132 -93

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ export async function run(_: {}, report: Function) {
const cursor = storage.coll.find({ path: { $regex: /^problem\//i } }).sort({ path: 1 });
const count = await cursor.count();
report({ message: `Total ${count} files` });
let current: string;
let current = '';
let memory = 0;
let start = new Date().getTime();
// eslint-disable-next-line no-constant-condition
@@ -1,30 +0,0 @@
import storage from '../model/storage';
import { iterateAllProblem, iterateAllProblemInDomain } from '../pipelineUtils';
export const description = 'Sync problem filelist from s3 service';
export async function run({ domainId }, report: Function) {
const cb = async (pdoc) => {
report({ message: `${pdoc.domainId}/${pdoc.docId}` });
const [data, additional_file] = await Promise.all([
storage.list(`problem/${pdoc.domainId}/${pdoc.docId}/testdata/`),
storage.list(`problem/${pdoc.domainId}/${pdoc.docId}/additional_file/`),
]) as any;
for (let i = 0; i < data.length; i++) {
data[i]._id = data[i].name;
}
for (let i = 0; i < additional_file.length; i++) {
additional_file[i]._id = additional_file[i].name;
}
return { data, additional_file };
};
if (domainId) await iterateAllProblemInDomain(domainId, [], cb);
else await iterateAllProblem([], cb);
return true;
}
export const validate = {
domainId: 'string?',
};
global.Hydro.script.updateFilelist = { run, description, validate };