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

Function addContestFile

packages/migrate/scripts/jnoj.ts:53–61  ·  view source on GitHub ↗
(domainId: string, tid: ObjectId, filename: string, filepath: string)

Source from the content-addressed store, hash-verified

51}
52
53async function addContestFile(domainId: string, tid: ObjectId, filename: string, filepath: string) {
54 const tdoc = await ContestModel.get(domainId, tid);
55 await StorageModel.put(`contest/${domainId}/${tid}/${filename}`, filepath, 1);
56 const meta = await StorageModel.getMeta(`contest/${domainId}/${tid}/${filename}`);
57 const payload = { _id: filename, name: filename, ..._.pick(meta, ['size', 'lastModified', 'etag']) };
58 if (!meta) return false;
59 await ContestModel.edit(domainId, tid, { files: [...(tdoc.files || []), payload] });
60 return true;
61}
62
63function fixFileName(fileName: string) {
64 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