MCPcopy Index your code
hub / github.com/hydro-dev/Hydro / addAdditionalFile

Method addAdditionalFile

packages/hydrooj/src/model/problem.ts:335–349  ·  view source on GitHub ↗
(
        domainId: string, pid: number, name: string,
        f: Readable | Buffer | string, operator = 1, skipUpload = false,
    )

Source from the content-addressed store, hash-verified

333 }
334
335 static async addAdditionalFile(
336 domainId: string, pid: number, name: string,
337 f: Readable | Buffer | string, operator = 1, skipUpload = false,
338 ) {
339 name = name.trim();
340 const [[, fileinfo]] = await Promise.all([
341 document.getSub(domainId, document.TYPE_PROBLEM, pid, 'additional_file', name),
342 skipUpload ? '' : storage.put(`problem/${domainId}/${pid}/additional_file/${name}`, f, operator),
343 ]);
344 const meta = await storage.getMeta(`problem/${domainId}/${pid}/additional_file/${name}`);
345 const payload = { name, ...pick(meta, ['size', 'lastModified', 'etag']) };
346 if (!fileinfo) await ProblemModel.push(domainId, pid, 'additional_file', { _id: name, ...payload });
347 else await document.setSub(domainId, document.TYPE_PROBLEM, pid, 'additional_file', name, payload);
348 await bus.emit('problem/addAdditionalFile', domainId, pid, name, payload);
349 }
350
351 static async renameAdditionalFile(domainId: string, pid: number, file: string, newName: string, operator = 1) {
352 if (file === newName) return;

Callers 8

runFunction · 0.80
runFunction · 0.80
runFunction · 0.80
runFunction · 0.80
runMethod · 0.80
importMethod · 0.80
postMethod · 0.80
syncMethod · 0.80

Calls 5

pickFunction · 0.85
allMethod · 0.45
putMethod · 0.45
getMetaMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected