Fix Travis errors due to broken DirectoryIterator
This commit is contained in:
parent
d89da85606
commit
6d07cb44df
3 changed files with 17 additions and 10 deletions
|
@ -494,6 +494,16 @@ var getTempDirectory = Zotero.Promise.coroutine(function* getTempDirectory() {
|
|||
return path;
|
||||
});
|
||||
|
||||
var removeDir = Zotero.Promise.coroutine(function* (dir) {
|
||||
// OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis,
|
||||
// returning entry.isDir == false for subdirectories, so use nsIFile instead
|
||||
//yield OS.File.removeDir(zipDir);
|
||||
dir = Zotero.File.pathToFile(dir);
|
||||
if (dir.exists()) {
|
||||
dir.remove(true);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Resets the Zotero DB and restarts Zotero. Returns a promise resolved
|
||||
* when this finishes.
|
||||
|
|
|
@ -140,10 +140,7 @@ describe("Zotero.Sync.Storage.Local", function () {
|
|||
yield Zotero.File.putContentsAsync(OS.Path.join(subDir, file3Name), file3Contents);
|
||||
|
||||
yield Zotero.File.zipDirectory(zipDir, zipFile);
|
||||
// OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis,
|
||||
// returning entry.isDir == false for subdirectories, so use nsIFile instead
|
||||
//yield OS.File.removeDir(zipDir);
|
||||
Zotero.File.pathToFile(zipDir).remove(true);
|
||||
yield removeDir(zipDir);
|
||||
});
|
||||
|
||||
it("should download and extract a ZIP file into the attachment directory", function* () {
|
||||
|
|
|
@ -42,8 +42,8 @@ describe("Zotero Core Functions", function () {
|
|||
});
|
||||
|
||||
afterEach(function* () {
|
||||
yield OS.File.removeDir(oldDir);
|
||||
yield OS.File.removeDir(newDir);
|
||||
yield removeDir(oldDir);
|
||||
yield removeDir(newDir);
|
||||
Zotero._cacheDataDirectory(false);
|
||||
|
||||
stub1.restore();
|
||||
|
@ -245,9 +245,9 @@ describe("Zotero Core Functions", function () {
|
|||
// Not moved: one storage dir, translators dir
|
||||
yield OS.File.remove(oldDBFile);
|
||||
yield OS.File.remove(oldDBFile + '.bak');
|
||||
yield OS.File.removeDir(oldStorageDir1);
|
||||
yield OS.File.removeDir(newTranslatorsDir);
|
||||
yield OS.File.removeDir(newStorageDir2);
|
||||
yield removeDir(oldStorageDir1);
|
||||
yield removeDir(newTranslatorsDir);
|
||||
yield removeDir(newStorageDir2);
|
||||
|
||||
yield Zotero.migrateDataDirectory(oldDir, newDir, true);
|
||||
yield checkMigration();
|
||||
|
@ -262,7 +262,7 @@ describe("Zotero Core Functions", function () {
|
|||
yield checkMigration();
|
||||
|
||||
assert.isTrue(yield OS.File.exists(OS.Path.join(newDir + "-1", 'existing')));
|
||||
yield OS.File.removeDir(newDir + "-1");
|
||||
yield removeDir(newDir + "-1");
|
||||
});
|
||||
|
||||
// Run all tests again without using mv
|
||||
|
|
Loading…
Reference in a new issue