(domainId: string, pid: number, file: string, newName: string, operator = 1)
| 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]; |
no test coverage detected