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

Method renameTestdata

packages/hydrooj/src/model/problem.ts:310–324  ·  view source on GitHub ↗
(domainId: string, pid: number, file: string, newName: string, operator = 1)

Source from the content-addressed store, hash-verified

308 }
309
310 static async renameTestdata(domainId: string, pid: number, file: string, newName: string, operator = 1) {
311 if (file === newName) return;
312 const [, sdoc] = await document.getSub(domainId, document.TYPE_PROBLEM, pid, 'data', newName);
313 if (sdoc) await ProblemModel.delTestdata(domainId, pid, newName);
314 const payload = { _id: newName, name: newName, lastModified: new Date() };
315 await Promise.all([
316 storage.rename(
317 `problem/${domainId}/${pid}/testdata/${file}`,
318 `problem/${domainId}/${pid}/testdata/${newName}`,
319 operator,
320 ),
321 document.setSub(domainId, document.TYPE_PROBLEM, pid, 'data', file, payload),
322 ]);
323 await bus.emit('problem/renameTestdata', domainId, pid, file, newName);
324 }
325
326 static async delTestdata(domainId: string, pid: number, name: string | string[], operator = 1) {
327 const names = (name instanceof Array) ? name : [name];

Callers 1

postRenameFilesMethod · 0.80

Calls 3

delTestdataMethod · 0.80
renameMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected