Start out empty if cache file is missing
This commit is contained in:
+1
-1
@@ -223,7 +223,7 @@ function sync(backupConfig, backupId, dataDir, callback) {
|
||||
var stream = fs.createReadStream(path.join(dataDir, task.path));
|
||||
stream.on('error', function () { return iteratorCallback(); }); // ignore error if file disappears
|
||||
api(backupConfig.provider).upload(backupConfig, getBackupFilePath(backupConfig, backupId, task.path), stream, iteratorCallback);
|
||||
} else if (task.operation === 'remove') {
|
||||
} else if (task.operation === 'remove' || task.operation === 'removedir') {
|
||||
safe.fs.writeFileSync(paths.BACKUP_RESULT_FILE, 'Removing ' + task.path);
|
||||
api(backupConfig.provider).remove(backupConfig, getBackupFilePath(backupConfig, backupId, task.path), iteratorCallback);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ function sync(dir, taskProcessor, concurrency, callback) {
|
||||
var cacheFile = path.join(paths.BACKUP_INFO_DIR, path.basename(dir) + '.sync.cache'),
|
||||
newCacheFile = path.join(paths.BACKUP_INFO_DIR, path.basename(dir) + '.sync.cache.new');
|
||||
|
||||
if (!safe.fs.existsSync(cacheFile)) { // if cache is missing, start out empty
|
||||
delQueue.push({ operation: 'removedir', path: '' });
|
||||
}
|
||||
|
||||
var cache = readCache(cacheFile);
|
||||
|
||||
var newCacheFd = safe.fs.openSync(newCacheFile, 'w'); // truncates any existing file
|
||||
|
||||
Reference in New Issue
Block a user