Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do not clean the target folder when the manifest file doesn't exist.

  • Loading branch information...
commit b8d134a12440c4a0aad9b88458afed6aa8b55490 1 parent 193ee52
@amitapl amitapl authored
View
9 bin/kuduSync.js
@@ -181,7 +181,6 @@ var DirectoryInfo = (function (_super) {
var Manifest = (function () {
function Manifest() {
this._files = new Array();
- this._isEmpty = true;
}
Manifest.load = function load(manifestPath) {
var manifest = new Manifest();
@@ -197,7 +196,6 @@ var Manifest = (function () {
files[file] = file;
}
});
- manifest._isEmpty = false;
manifest._files = files;
return Q.resolve(manifest);
}, function (err) {
@@ -233,9 +231,6 @@ var Manifest = (function () {
var relativePath = pathUtil.relative(rootPath, path);
this._files[relativePath] = relativePath;
};
- Manifest.prototype.isEmpty = function () {
- return this._isEmpty;
- };
return Manifest;
})();
function kuduSync(fromPath, toPath, nextManifestPath, previousManifestPath, ignore, whatIf) {
@@ -372,7 +367,7 @@ function kuduSyncDirectory(from, to, fromRootPath, toRootPath, manifest, outMani
return Q.resolve();
}
if(!from.getFile(toFile.name())) {
- if(manifest.isEmpty() || manifest.isPathInManifest(toFile.path(), toRootPath)) {
+ if(manifest.isPathInManifest(toFile.path(), toRootPath)) {
return deleteFile(toFile, whatIf);
}
}
@@ -393,7 +388,7 @@ function kuduSyncDirectory(from, to, fromRootPath, toRootPath, manifest, outMani
}, function () {
return Q.all(Utils.map(to.subDirectoriesList(), function (toSubDirectory) {
if(!from.getSubDirectory(toSubDirectory.name())) {
- if(manifest.isEmpty() || manifest.isPathInManifest(toSubDirectory.path(), toRootPath)) {
+ if(manifest.isPathInManifest(toSubDirectory.path(), toRootPath)) {
return deleteDirectoryRecursive(toSubDirectory, whatIf);
}
}
View
4 lib/FileUtils.ts
@@ -178,7 +178,7 @@ function kuduSyncDirectory(from: DirectoryInfo, to: DirectoryInfo, fromRootPath:
}
if (!from.getFile(toFile.name())) {
- if (manifest.isEmpty() || manifest.isPathInManifest(toFile.path(), toRootPath)) {
+ if (manifest.isPathInManifest(toFile.path(), toRootPath)) {
return deleteFile(toFile, whatIf);
}
}
@@ -220,7 +220,7 @@ function kuduSyncDirectory(from: DirectoryInfo, to: DirectoryInfo, fromRootPath:
// 1. We have no previous directory
// 2. We have a previous directory and the file exists there
if (!from.getSubDirectory(toSubDirectory.name())) {
- if (manifest.isEmpty() || manifest.isPathInManifest(toSubDirectory.path(), toRootPath)) {
+ if (manifest.isPathInManifest(toSubDirectory.path(), toRootPath)) {
return deleteDirectoryRecursive(toSubDirectory, whatIf);
}
}
View
7 lib/Manifest.ts
@@ -3,11 +3,9 @@
class Manifest {
private _files: string[];
- private _isEmpty: bool;
constructor () {
this._files = new string[];
- this._isEmpty = true;
}
static load(manifestPath: string) {
@@ -29,7 +27,6 @@ class Manifest {
}
}
);
- manifest._isEmpty = false;
manifest._files = files;
return Q.resolve(manifest);
},
@@ -76,8 +73,4 @@ class Manifest {
var relativePath = pathUtil.relative(rootPath, path);
this._files[relativePath] = relativePath;
}
-
- isEmpty() {
- return this._isEmpty;
- }
}
View
6 test/functionalTests.js
@@ -97,14 +97,14 @@ suite('Kudu Sync Functional Tests', function () {
});
});
- test('No previous manifest will clean target directory', function (done) {
+ test('No previous manifest will not clean target directory', function (done) {
runKuduSyncTestScenario(["file1"], ["file1"], null, function () {
// Generating files only in the destination directory, those files shouldn't be removed
generateToFile("tofile2");
runKuduSyncTestScenario(["-file1"], ["-file1", "tofile2"], null, function () {
removeManifestFile();
- runKuduSyncTestScenario(["file1"], ["file1", "-tofile2"], null, done);
+ runKuduSyncTestScenario(["file1"], ["file1", "tofile2"], null, done);
});
});
});
@@ -237,7 +237,7 @@ suite('Kudu Sync Functional Tests', function () {
test('Clean before sync when it\'s the first sync (manifest is empty)', function (done) {
generateToFile("dir1/dir2/tofile3");
var testedFiles = ["file4", "file5", "file6"];
- var expectedFiles = ["file4", "file5", "file6", "-dir1/dir2/tofile3"];
+ var expectedFiles = ["file4", "file5", "file6", "dir1/dir2/tofile3"];
runKuduSyncTestScenario(testedFiles, expectedFiles, null, done);
});
Please sign in to comment.
Something went wrong with that request. Please try again.