Compare commits
2 Commits
fdroid-v0.
...
auth-v4.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2854b344c | ||
|
|
96d9637de1 |
@@ -42,7 +42,7 @@ class DirectoryUtils {
|
||||
return await getTemporaryDirectory();
|
||||
}
|
||||
|
||||
static String migratedNamingChanges = "migrated_naming_changes.b5";
|
||||
static String migratedNamingChanges = "migrated_naming_changes.b6";
|
||||
static migrateNamingChanges() async {
|
||||
try {
|
||||
final sharedPrefs = await SharedPreferences.getInstance();
|
||||
@@ -64,7 +64,8 @@ class DirectoryUtils {
|
||||
),
|
||||
);
|
||||
Directory oldDataDir;
|
||||
Directory newDataDir;
|
||||
Directory newDataDir = await getApplicationSupportDirectory();
|
||||
await newDataDir.create(recursive: true);
|
||||
|
||||
Directory? tempDir;
|
||||
if (Platform.isLinux) {
|
||||
@@ -74,19 +75,36 @@ class DirectoryUtils {
|
||||
tempDir = Directory(
|
||||
p.join(dataHome.path, "enteauth"),
|
||||
);
|
||||
if (tempDir.existsSync()) {
|
||||
oldDataDir = tempDir;
|
||||
}
|
||||
if (await oldDataDir.exists()) {
|
||||
await copyPath(oldDataDir.path, newDataDir.path);
|
||||
}
|
||||
} else if (Platform.isWindows) {
|
||||
oldDataDir = Directory(
|
||||
p.join(
|
||||
(await getApplicationDocumentsDirectory()).path,
|
||||
"ente",
|
||||
),
|
||||
);
|
||||
tempDir = Directory(
|
||||
p.join(
|
||||
(await getApplicationDocumentsDirectory()).path,
|
||||
"enteauth",
|
||||
),
|
||||
);
|
||||
tempDir = oldDataDir;
|
||||
if (tempDir.existsSync()) {
|
||||
databaseFile = File(
|
||||
p.join(
|
||||
(await getApplicationDocumentsDirectory()).path,
|
||||
"enteauth",
|
||||
".ente.authenticator.db",
|
||||
),
|
||||
);
|
||||
offlineDatabaseFile = File(
|
||||
p.join(
|
||||
(await getApplicationDocumentsDirectory()).path,
|
||||
"enteauth",
|
||||
".ente.offline_authenticator.db",
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
oldDataDir = await getApplicationDocumentsDirectory();
|
||||
databaseFile = File(
|
||||
@@ -103,31 +121,20 @@ class DirectoryUtils {
|
||||
);
|
||||
}
|
||||
|
||||
if (tempDir?.existsSync() ?? false) {
|
||||
oldDataDir = tempDir!;
|
||||
}
|
||||
newDataDir = await getApplicationSupportDirectory();
|
||||
await newDataDir.create(recursive: true);
|
||||
|
||||
final prefix = Platform.isMacOS ? "" : ".";
|
||||
File newDatabaseFile =
|
||||
File(p.join(newDataDir.path, "${prefix}ente.authenticator.db"));
|
||||
if (await databaseFile.exists() && !await newDatabaseFile.exists()) {
|
||||
if (await databaseFile.exists()) {
|
||||
await databaseFile.copy(newDatabaseFile.path);
|
||||
}
|
||||
|
||||
File newOfflineDatabaseFile = File(
|
||||
p.join(newDataDir.path, "${prefix}ente.offline_authenticator.db"),
|
||||
);
|
||||
if (await offlineDatabaseFile.exists() &&
|
||||
!await newOfflineDatabaseFile.exists()) {
|
||||
if (await offlineDatabaseFile.exists()) {
|
||||
await offlineDatabaseFile.copy(newOfflineDatabaseFile.path);
|
||||
}
|
||||
|
||||
if (Platform.isLinux && await oldDataDir.exists()) {
|
||||
await copyPath(oldDataDir.path, newDataDir.path);
|
||||
}
|
||||
|
||||
sharedPrefs.setBool(migratedNamingChanges, true).ignore();
|
||||
} catch (e, st) {
|
||||
logger.warning("Migrating Database failed!", e, st);
|
||||
|
||||
Reference in New Issue
Block a user