Permalink
Browse files

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

  • Loading branch information...
1 parent 193ee52 commit b8d134a12440c4a0aad9b88458afed6aa8b55490 Amit Apple committed Nov 26, 2012
Showing with 7 additions and 19 deletions.
  1. +2 −7 bin/kuduSync.js
  2. +2 −2 lib/FileUtils.ts
  3. +0 −7 lib/Manifest.ts
  4. +3 −3 test/functionalTests.js
View
@@ -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
@@ -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
@@ -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
@@ -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);
});

0 comments on commit b8d134a

Please sign in to comment.