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

Method createDirectory

lib/ldp.mjs:283–305  ·  view source on GitHub ↗

* Create directory if not exists * Add pubsub if creating intermediate directory to a non-container * * @param {*} path * @param {*} hostname * @param {*} nonContainer

(pathArg, hostname, nonContainer = true)

Source from the content-addressed store, hash-verified

281 * @param {*} nonContainer
282 */
283 async createDirectory (pathArg, hostname, nonContainer = true) {
284 try {
285 const dirName = dirname(pathArg)
286 if (!fs.existsSync(dirName)) {
287 await promisify(mkdirp)(dirName)
288 if (this.live && nonContainer) {
289 // Get parent for the directory made
290 const parentDirectoryPath = utilPath.dirname(dirName) + utilPath.sep
291
292 // Get the url for the parent
293 const parentDirectoryUrl = (await this.resourceMapper.mapFileToUrl({
294 path: parentDirectoryPath,
295 hostname
296 })).url
297 // Update websockets
298 this.live(urlModule.parse(parentDirectoryUrl).pathname)
299 }
300 }
301 } catch (err) {
302 debug.handlers('PUT -- Error creating directory: ' + err)
303 throw error(err, 'Failed to create the path to the new resource')
304 }
305 }
306
307 async checkFileExtension (urlArg, pathArg) {
308 try {

Callers 2

putMethod · 0.95
patchHandlerFunction · 0.80

Calls 1

mapFileToUrlMethod · 0.80

Tested by

no test coverage detected