Don't auto-migrate data dir if target on a different drive
See https://forums.zotero.org/discussion/comment/277632/#Comment_277632
This commit is contained in:
parent
98544edde5
commit
a17b486e4b
3 changed files with 108 additions and 31 deletions
|
@ -39,10 +39,12 @@ describe("Zotero.DataDirectory", function () {
|
|||
stubs.canMigrate = sinon.stub(Zotero.DataDirectory, "canMigrate").returns(true);
|
||||
// A pipe always exists during tests, since Zotero is running
|
||||
stubs.pipeExists = sinon.stub(Zotero.IPC, "pipeExists").returns(Zotero.Promise.resolve(false));
|
||||
stubs.setDataDir = sinon.stub(Zotero.DataDirectory, "set");
|
||||
stubs.isNewDirOnDifferentDrive = sinon.stub(Zotero.DataDirectory, 'isNewDirOnDifferentDrive').resolves(true);
|
||||
});
|
||||
|
||||
beforeEach(function* () {
|
||||
stubs.setDataDir = sinon.stub(Zotero.DataDirectory, "set");
|
||||
stubs.setDataDir.reset();
|
||||
});
|
||||
|
||||
afterEach(function* () {
|
||||
|
@ -50,13 +52,14 @@ describe("Zotero.DataDirectory", function () {
|
|||
yield removeDir(newDir);
|
||||
Zotero.DataDirectory._cache(false);
|
||||
yield Zotero.DataDirectory.init();
|
||||
|
||||
stubs.setDataDir.restore();
|
||||
});
|
||||
|
||||
after(function* () {
|
||||
stubs.canMigrate.restore();
|
||||
stubs.pipeExists.restore();
|
||||
for (let key in stubs) {
|
||||
try {
|
||||
stubs[key].restore();
|
||||
} catch(e) {}
|
||||
}
|
||||
});
|
||||
|
||||
// Force non-mv mode
|
||||
|
@ -183,6 +186,28 @@ describe("Zotero.DataDirectory", function () {
|
|||
yield assert.eventually.isFalse(Zotero.DataDirectory.checkForMigration(oldDir, newDir));
|
||||
});
|
||||
|
||||
it("should skip automatic migration and show prompt if target directory is on a different drive", function* () {
|
||||
resetCommandMode();
|
||||
resetFunctionMode();
|
||||
|
||||
yield populateDataDirectory(oldDir);
|
||||
yield OS.File.remove(oldMigrationMarker);
|
||||
|
||||
stubs.isNewDirOnDifferentDrive.resolves(true);
|
||||
|
||||
var promise = waitForDialog(function (dialog) {
|
||||
assert.include(
|
||||
dialog.document.documentElement.textContent,
|
||||
Zotero.getString(`dataDir.migration.failure.full.automatic.newDirOnDifferentDrive`, Zotero.clientName)
|
||||
);
|
||||
}, 'cancel');
|
||||
|
||||
yield assert.eventually.isNotOk(Zotero.DataDirectory.checkForMigration(oldDir, newDir));
|
||||
yield promise;
|
||||
|
||||
stubs.isNewDirOnDifferentDrive.resolves(false);
|
||||
});
|
||||
|
||||
add("should show error on partial failure", function (automatic) {
|
||||
return function* () {
|
||||
yield populateDataDirectory(oldDir, null, automatic);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue