| 519 | let overridePid = null; |
| 520 | |
| 521 | const isValidPid = async (id: string) => { |
| 522 | if (!(/^(?:[a-z0-9]{1,10}-)?[a-z][0-9a-z]*$/i.test(id))) return false; |
| 523 | if (id.includes('-')) { |
| 524 | const [prefix] = id.split('-'); |
| 525 | if (!ddoc?.namespaces?.[prefix]) return false; |
| 526 | } |
| 527 | const doc = await ProblemModel.get(ddoc._id, id); |
| 528 | if (doc) { |
| 529 | if (!override) return false; |
| 530 | overridePid = doc.docId; |
| 531 | return true; |
| 532 | } |
| 533 | return true; |
| 534 | }; |
| 535 | const getFiles = async (...type: string[]): Promise<[fs.Dirent, string][]> => { |
| 536 | if (type.length > 1) { |
| 537 | let result = []; |