Move auto-migration checks into checkForDataDirectoryMigration()
This commit is contained in:
parent
a4ab84eed3
commit
678fe77fbb
|
@ -318,12 +318,6 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Zotero.isConnector) {
|
if (!Zotero.isConnector) {
|
||||||
// On macOS and Linux, migrate the data directory automatically
|
|
||||||
if (this.canMigrateDataDirectory(dataDir.path)
|
|
||||||
// Should match check in Zotero.File.moveDirectory()
|
|
||||||
&& !Zotero.isWin && (yield OS.File.exists("/bin/mv"))) {
|
|
||||||
yield this.markDataDirectoryForMigration(dataDir.path, true);
|
|
||||||
}
|
|
||||||
yield Zotero.checkForDataDirectoryMigration(dataDir.path, this.getDefaultDataDir());
|
yield Zotero.checkForDataDirectoryMigration(dataDir.path, this.getDefaultDataDir());
|
||||||
if (this.skipLoading) {
|
if (this.skipLoading) {
|
||||||
return;
|
return;
|
||||||
|
@ -1480,6 +1474,10 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
* the default data directory
|
* the default data directory
|
||||||
*/
|
*/
|
||||||
this.checkForDataDirectoryMigration = Zotero.Promise.coroutine(function* (dataDir, newDir) {
|
this.checkForDataDirectoryMigration = Zotero.Promise.coroutine(function* (dataDir, newDir) {
|
||||||
|
if (!this.canMigrateDataDirectory(dataDir)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let migrationMarker = OS.Path.join(dataDir, this.DATA_DIR_MIGRATION_MARKER);
|
let migrationMarker = OS.Path.join(dataDir, this.DATA_DIR_MIGRATION_MARKER);
|
||||||
try {
|
try {
|
||||||
var exists = yield OS.File.exists(migrationMarker)
|
var exists = yield OS.File.exists(migrationMarker)
|
||||||
|
@ -1487,10 +1485,23 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
}
|
}
|
||||||
|
let automatic = false;
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
return false;
|
// Migrate automatically on macOS and Linux -- this should match the check in
|
||||||
|
// Zotero.File.moveDirectory()
|
||||||
|
if (!Zotero.isWin && (yield OS.File.exists("/bin/mv"))) {
|
||||||
|
automatic = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (automatic) {
|
||||||
|
yield this.markDataDirectoryForMigration(dataDir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
let sourceDir;
|
||||||
let oldDir;
|
let oldDir;
|
||||||
let partial = false;
|
let partial = false;
|
||||||
|
|
||||||
|
@ -1498,7 +1509,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
let contents;
|
let contents;
|
||||||
try {
|
try {
|
||||||
contents = yield Zotero.File.getContentsAsync(migrationMarker);
|
contents = yield Zotero.File.getContentsAsync(migrationMarker);
|
||||||
var { sourceDir, automatic } = JSON.parse(contents);
|
({ sourceDir, automatic } = JSON.parse(contents));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (contents !== undefined) {
|
if (contents !== undefined) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user