Adjust removeBackup() api

This commit is contained in:
Johannes Zellner
2016-10-10 15:45:12 +02:00
parent 1b3ae1f178
commit c7e5c09bb9
5 changed files with 20 additions and 8 deletions

View File

@@ -112,12 +112,20 @@ function copyObject(apiConfig, from, to, callback) {
readStream.pipe(writeStream);
}
function removeBackup(apiConfig, backupId, callback) {
function removeBackup(apiConfig, backupId, appBackupIds, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
assert(Array.isArray(appBackupIds));
assert.strictEqual(typeof callback, 'function');
// Result: none
var backupFolder = apiConfig.backupFolder || FALLBACK_BACKUP_FOLDER;
callback(new Error('not implemented'));
var tmp = [backupId].concat(appBackupIds);
tmp.forEach(function (id) {
var filePath = path.join(backupFolder, id);
var success = safe.fs.unlinkSync(filePath);
if (!success) console.error('Unable to remove %s. Not fatal.', filePath, safe.error);
});
callback();
}