mirror of
https://github.com/nini22P/iris.git
synced 2026-09-03 14:28:50 +08:00
update the data path for windows version
This commit is contained in:
@@ -12,6 +12,7 @@ import 'package:iris/pages/home_page.dart';
|
||||
import 'package:iris/store/use_app_store.dart';
|
||||
import 'package:iris/store/use_play_queue_store.dart';
|
||||
import 'package:iris/theme.dart';
|
||||
import 'package:iris/utils/data_migration.dart';
|
||||
import 'package:iris/utils/is_desktop.dart';
|
||||
import 'package:iris/utils/logger.dart';
|
||||
import 'package:iris/utils/request_storage_permission.dart';
|
||||
@@ -28,6 +29,10 @@ void main(List<String> arguments) async {
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
if (Platform.isWindows) {
|
||||
await dataMigration();
|
||||
}
|
||||
|
||||
MediaKit.ensureInitialized();
|
||||
|
||||
fvp.registerWith(options: {
|
||||
|
||||
46
lib/utils/data_migration.dart
Normal file
46
lib/utils/data_migration.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'dart:io';
|
||||
import 'package:iris/utils/logger.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
Future<bool> dataMigration() async {
|
||||
try {
|
||||
if (Platform.isWindows) {
|
||||
final String newDataPath = (await getApplicationSupportDirectory()).path;
|
||||
final String oldDataPath =
|
||||
p.normalize('$newDataPath/../../nini22p.iris/iris');
|
||||
logger('newDataPath: $newDataPath');
|
||||
logger('oldDataPath: $oldDataPath');
|
||||
final bool newDataExist =
|
||||
await File('$newDataPath/flutter_secure_storage.dat').exists();
|
||||
final bool oldDataExist =
|
||||
await File('$oldDataPath/flutter_secure_storage.dat').exists();
|
||||
if (!newDataExist && oldDataExist) {
|
||||
logger('Find old data in $oldDataPath');
|
||||
final Directory oldDir = Directory(oldDataPath);
|
||||
final Directory newDir = Directory(newDataPath);
|
||||
|
||||
if (await oldDir.exists()) {
|
||||
if (!await newDir.exists()) {
|
||||
await newDir.create(recursive: true);
|
||||
}
|
||||
|
||||
await for (var entity in oldDir.list()) {
|
||||
if (entity is File) {
|
||||
final String newFilePath =
|
||||
p.join(newDir.path, p.basename(entity.path));
|
||||
await entity.copy(newFilePath);
|
||||
logger('Copied ${entity.path} to $newFilePath');
|
||||
}
|
||||
}
|
||||
logger('Data migration completed');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "nini22p.iris" "\0"
|
||||
VALUE "CompanyName", "nini22P" "\0"
|
||||
VALUE "FileDescription", "iris" "\0"
|
||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||
VALUE "InternalName", "iris" "\0"
|
||||
|
||||
Reference in New Issue
Block a user