MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / deleteContainer

Method deleteContainer

lib/ldp.mjs:528–550  ·  view source on GitHub ↗
(directory)

Source from the content-addressed store, hash-verified

526 }
527
528 async deleteContainer (directory) {
529 if (directory[directory.length - 1] !== '/') directory += '/'
530
531 // Ensure the container exists
532 let list
533 try {
534 list = await promisify(fs.readdir)(directory)
535 } catch (err) {
536 throw error(404, 'The container does not exist')
537 }
538
539 // Ensure the container is empty (we ignore .meta and .acl)
540 if (list.some(file => !file.endsWith(this.suffixMeta) && !file.endsWith(this.suffixAcl))) {
541 throw error(409, 'Container is not empty')
542 }
543
544 // Delete the directory recursively
545 try {
546 await promisify(rimraf)(directory)
547 } catch (err) {
548 throw error(err, 'Failed to delete the container')
549 }
550 }
551
552 // delete document (resource with acl and meta links)
553 async deleteDocument (filePath) {

Callers 1

deleteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected