MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / addContestFile

Function addContestFile

packages/migrate/scripts/hustoj.ts:47–55  ·  view source on GitHub ↗
(domainId: string, tid: ObjectId, filename: string, filepath: string)

Source from the content-addressed store, hash-verified

45};
46
47async function addContestFile(domainId: string, tid: ObjectId, filename: string, filepath: string) {
48 const tdoc = await ContestModel.get(domainId, tid);
49 await StorageModel.put(`contest/${domainId}/${tid}/${filename}`, filepath, 1);
50 const meta = await StorageModel.getMeta(`contest/${domainId}/${tid}/${filename}`);
51 const payload = { _id: filename, name: filename, ..._.pick(meta, ['size', 'lastModified', 'etag']) };
52 if (!meta) return false;
53 await ContestModel.edit(domainId, tid, { files: [...(tdoc.files || []), payload] });
54 return true;
55}
56
57function fixFileName(fileName: string) {
58 if (fileName.endsWith('.in') || fileName.endsWith('.out')) {

Callers 1

runFunction · 0.70

Calls 4

getMethod · 0.45
putMethod · 0.45
getMetaMethod · 0.45
editMethod · 0.45

Tested by

no test coverage detected