(url)
| 494 | } |
| 495 | |
| 496 | async delete (url) { |
| 497 | // First check if the path points to a valid file |
| 498 | let path, stats |
| 499 | try { |
| 500 | ({ path } = await this.resourceMapper.mapUrlToFile({ url })) |
| 501 | stats = await this.stat(path) |
| 502 | } catch (err) { |
| 503 | throw error(404, "Can't find " + err) |
| 504 | } |
| 505 | |
| 506 | // delete aclCache |
| 507 | let aclUrl = typeof url !== 'string' ? this.resourceMapper.getRequestUrl(url) : url |
| 508 | aclUrl = aclUrl.endsWith(this.suffixAcl) ? aclUrl : aclUrl + this.suffixAcl |
| 509 | debug.handlers('DELETE ACL CACHE ' + aclUrl) |
| 510 | clearAclCache(aclUrl) |
| 511 | |
| 512 | // If so, delete the directory or file |
| 513 | if (stats.isDirectory()) { |
| 514 | // DELETE method not allowed on podRoot |
| 515 | if ((url.url || url) === '/') { |
| 516 | throw error(405, 'DELETE of PodRoot is not allowed') |
| 517 | } |
| 518 | return this.deleteContainer(path) |
| 519 | } else { |
| 520 | // DELETE method not allowed on podRoot/.acl |
| 521 | if (['/' + this.suffixAcl, '/profile/card'].some(item => (url.url || url) === item)) { |
| 522 | throw error(405, `DELETE of ${url.url || url} is not allowed`) |
| 523 | } |
| 524 | return this.deleteDocument(path) |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | async deleteContainer (directory) { |
| 529 | if (directory[directory.length - 1] !== '/') directory += '/' |
no test coverage detected