targz: make sourceDir a string

This commit is contained in:
Girish Ramakrishnan
2017-09-17 18:50:15 -07:00
parent 867a59d5d8
commit b0ee116004
4 changed files with 7 additions and 9 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ function backup(apiConfig, backupId, sourceDir, callback) {
callback(null);
});
targz.create([{ source: sourceDir, destination: '.' }], apiConfig.key || null, passThrough, callback);
targz.create(sourceDir, apiConfig.key || null, passThrough, callback);
});
}
+1 -1
View File
@@ -69,7 +69,7 @@ function backup(apiConfig, backupId, sourceDir, callback) {
callback(null);
});
targz.create([{ source: sourceDir, destination: '.' }], apiConfig.key || null, fileStream, callback);
targz.create(sourceDir, apiConfig.key || null, fileStream, callback);
});
}
+1 -1
View File
@@ -100,7 +100,7 @@ function backup(apiConfig, backupId, sourceDir, callback) {
callback(null);
});
targz.create([{ source: sourceDir, destination: '.' }], apiConfig.key || null, passThrough, callback);
targz.create(sourceDir, apiConfig.key || null, passThrough, callback);
});
}
+4 -6
View File
@@ -14,18 +14,16 @@ var assert = require('assert'),
tar = require('tar-fs'),
zlib = require('zlib');
function create(sourceDirectories, key, outStream, callback) {
assert(Array.isArray(sourceDirectories));
function create(sourceDir, key, outStream, callback) {
assert.strictEqual(typeof sourceDir, 'string');
assert(key === null || typeof key === 'string');
assert.strictEqual(typeof callback, 'function');
var pack = tar.pack('/', {
dereference: false, // pack the symlink and not what it points to
entries: sourceDirectories.map(function (m) { return m.source; }),
entries: [ sourceDir ],
map: function(header) {
sourceDirectories.forEach(function (m) {
header.name = header.name.replace(new RegExp('^' + m.source + '(/?)'), m.destination + '$1');
});
header.name = header.name.replace(new RegExp('^' + sourceDir + '(/?)'), '.$1'); // make paths relative
return header;
},
strict: false // do not error for unknown types (skip fifo, char/block devices)