mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
fix(auth): add migrate naming changes for linux
This commit is contained in:
parent
2e01a96477
commit
6af1604026
@ -23,6 +23,7 @@ import 'package:ente_auth/store/code_store.dart';
|
||||
import 'package:ente_auth/ui/tools/app_lock.dart';
|
||||
import 'package:ente_auth/ui/tools/lock_screen.dart';
|
||||
import 'package:ente_auth/ui/utils/icon_utils.dart';
|
||||
import 'package:ente_auth/utils/directory_utils.dart';
|
||||
import 'package:ente_auth/utils/lock_screen_settings.dart';
|
||||
import 'package:ente_auth/utils/platform_util.dart';
|
||||
import 'package:ente_auth/utils/window_protocol_handler.dart';
|
||||
@ -69,6 +70,10 @@ void main() async {
|
||||
HttpOverrides.global = WindowsHttpOverrides();
|
||||
}
|
||||
|
||||
if (Platform.isLinux) {
|
||||
await DirectoryUtils.migrateNamingChanges();
|
||||
}
|
||||
|
||||
if (PlatformUtil.isDesktop()) {
|
||||
await windowManager.ensureInitialized();
|
||||
await WindowListenerService.instance.init();
|
||||
|
@ -48,4 +48,48 @@ class DirectoryUtils {
|
||||
static Future<Directory> getTempsDir() async {
|
||||
return await getTemporaryDirectory();
|
||||
}
|
||||
|
||||
static migrateNamingChanges() async {
|
||||
final databaseFile = File(
|
||||
p.join(
|
||||
(await getApplicationDocumentsDirectory()).path,
|
||||
"ente",
|
||||
".ente.authenticator.db",
|
||||
),
|
||||
);
|
||||
final offlineDatabaseFile = File(
|
||||
p.join(
|
||||
(await getApplicationDocumentsDirectory()).path,
|
||||
"ente",
|
||||
".ente.offline_authenticator.db",
|
||||
),
|
||||
);
|
||||
|
||||
final oldDataDir = Directory(
|
||||
p.join(dataHome.path, "ente_auth"),
|
||||
);
|
||||
final newDir = Directory(
|
||||
p.join(dataHome.path, "enteauth"),
|
||||
);
|
||||
await newDir.create(recursive: true);
|
||||
|
||||
if (await databaseFile.exists()) {
|
||||
await databaseFile.rename(
|
||||
p.join(newDir.path, ".ente.authenticator.db"),
|
||||
);
|
||||
}
|
||||
|
||||
if (await offlineDatabaseFile.exists()) {
|
||||
await offlineDatabaseFile.rename(
|
||||
p.join(newDir.path, ".ente.offline_authenticator.db"),
|
||||
);
|
||||
}
|
||||
|
||||
if (await oldDataDir.exists()) {
|
||||
await oldDataDir.list().forEach((file) async {
|
||||
await file.rename(p.join(newDir.path, p.basename(file.path)));
|
||||
});
|
||||
await oldDataDir.delete(recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user