mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: script: add sync file list
This commit is contained in:
1 parent
8d3dc160a8
commit
96006d88b1
4 files changed
+69
-14
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import storage from '../service/storage';
|
||||
import { iterateAllProblem, iterateAllProblemInDomain } from '../upgrade';
|
||||
|
||||
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_files/`),
|
||||
]) 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 = {
|
||||
$or: [
|
||||
{ domainId: 'string' },
|
||||
{ domainId: 'undefined' },
|
||||
],
|
||||
};
|
||||
|
||||
global.Hydro.script.updateFilelist = { run, description, validate };
|
||||
Reference in new issue
Block a user