* 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)
| 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 { |
no test coverage detected