backups: remove entries from database that don't exist in storage
fixes #772
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getBackupPath: getBackupPath,
|
||||
checkPreconditions: checkPreconditions,
|
||||
getBackupPath,
|
||||
checkPreconditions,
|
||||
|
||||
upload: upload,
|
||||
download: download,
|
||||
upload,
|
||||
download,
|
||||
|
||||
copy: copy,
|
||||
copy,
|
||||
|
||||
listDir: listDir,
|
||||
exists,
|
||||
listDir,
|
||||
|
||||
remove: remove,
|
||||
removeDir: removeDir,
|
||||
remove,
|
||||
removeDir,
|
||||
|
||||
testConfig: testConfig,
|
||||
removePrivateFields: removePrivateFields,
|
||||
injectPrivateFields: injectPrivateFields
|
||||
testConfig,
|
||||
removePrivateFields,
|
||||
injectPrivateFields
|
||||
};
|
||||
|
||||
const PROVIDER_FILESYSTEM = 'filesystem';
|
||||
@@ -136,6 +137,20 @@ function download(apiConfig, sourceFilePath, callback) {
|
||||
callback(null, fileStream);
|
||||
}
|
||||
|
||||
function exists(apiConfig, sourceFilePath, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof sourceFilePath, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
// do not use existsSync because it does not return EPERM etc
|
||||
if (!safe.fs.statSync(sourceFilePath)) {
|
||||
if (safe.error && safe.error.code === 'ENOENT') return callback(null, false);
|
||||
if (safe.error) return callback(new BoxError(BoxError.EXTERNAL_ERROR, `Exists ${sourceFilePath}: ${safe.error.message}`));
|
||||
}
|
||||
|
||||
callback(null, true);
|
||||
}
|
||||
|
||||
function listDir(apiConfig, dir, batchSize, iteratorCallback, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof dir, 'string');
|
||||
|
||||
Reference in New Issue
Block a user