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

Method addTestdata

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

Source from the content-addressed store, hash-verified

292 }
293
294 static async addTestdata(domainId: string, pid: number, name: string, f: Readable | Buffer | string, operator = 1) {
295 name = name.trim();
296 if (!name) throw new ValidationError('name');
297 const [[, fileinfo]] = await Promise.all([
298 document.getSub(domainId, document.TYPE_PROBLEM, pid, 'data', name),
299 storage.put(`problem/${domainId}/${pid}/testdata/${name}`, f, operator),
300 ]);
301 const meta = await storage.getMeta(`problem/${domainId}/${pid}/testdata/${name}`);
302 if (!meta) throw new FileUploadError();
303 const payload = { name, ...pick(meta, ['size', 'lastModified', 'etag']) };
304 payload.lastModified ||= new Date();
305 if (!fileinfo) await ProblemModel.push(domainId, pid, 'data', { _id: name, ...payload });
306 else await document.setSub(domainId, document.TYPE_PROBLEM, pid, 'data', name, payload);
307 await bus.emit('problem/addTestdata', domainId, pid, name, payload);
308 }
309
310 static async renameTestdata(domainId: string, pid: number, file: string, newName: string, operator = 1) {
311 if (file === newName) return;

Callers 14

fromFileMethod · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
startPerformanceTestFunction · 0.45
applyFunction · 0.45
upgrade.tsFile · 0.45
importMethod · 0.45
processJudgeFileCallbackFunction · 0.45
applyFunction · 0.45

Calls 5

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

Tested by

no test coverage detected