|
|
@ -1,6 +1,6 @@ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Way data is stored for this database. |
|
|
|
* Way data is stored for this database. |
|
|
|
* This version is the Node.js/Node Webkit version. |
|
|
|
* This version is the Node.js version. |
|
|
|
* It's essentially fs, mkdirp and crash safe write and read functions. |
|
|
|
* It's essentially fs, mkdirp and crash safe write and read functions. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see module:storageBrowser |
|
|
|
* @see module:storageBrowser |
|
|
@ -271,6 +271,22 @@ const ensureDatafileIntegrityAsync = async (filename, mode = DEFAULT_FILE_MODE) |
|
|
|
else await renameAsync(tempFilename, filename) |
|
|
|
else await renameAsync(tempFilename, filename) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Check if a file's parent directory of exists and create it on the fly if it is not the case. |
|
|
|
|
|
|
|
* @param {string} filename |
|
|
|
|
|
|
|
* @param {number} mode |
|
|
|
|
|
|
|
* @return {Promise<void>} |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const ensureParentDirectoryExistsAsync = async (filename, mode) => { |
|
|
|
|
|
|
|
const dir = path.dirname(filename) |
|
|
|
|
|
|
|
const parsedDir = path.parse(path.resolve(dir)) |
|
|
|
|
|
|
|
// this is because on Windows mkdir throws a permission error when called on the root directory of a volume
|
|
|
|
|
|
|
|
if (process.platform !== 'win32' || parsedDir.dir !== parsedDir.root || parsedDir.base !== '') { |
|
|
|
|
|
|
|
await mkdirAsync(dir, { recursive: true, mode }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Interface
|
|
|
|
// Interface
|
|
|
|
module.exports.existsAsync = existsAsync |
|
|
|
module.exports.existsAsync = existsAsync |
|
|
|
|
|
|
|
|
|
|
@ -297,3 +313,5 @@ module.exports.flushToStorageAsync = flushToStorageAsync |
|
|
|
module.exports.ensureDatafileIntegrityAsync = ensureDatafileIntegrityAsync |
|
|
|
module.exports.ensureDatafileIntegrityAsync = ensureDatafileIntegrityAsync |
|
|
|
|
|
|
|
|
|
|
|
module.exports.ensureFileDoesntExistAsync = ensureFileDoesntExistAsync |
|
|
|
module.exports.ensureFileDoesntExistAsync = ensureFileDoesntExistAsync |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports.ensureParentDirectoryExistsAsync = ensureParentDirectoryExistsAsync |
|
|
|