mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 21:03:41 +00:00
Merge branch 'main' into codex/async-ffi-worker-callbacks
This commit is contained in:
14 files changed
+136
-79
No files matched your search
@@ -210,7 +210,7 @@ class _ExtensionsPageState extends ConsumerState<ExtensionsPage> {
|
||||
}
|
||||
|
||||
Future<void> _installFromFolder() async {
|
||||
final folder = await FilePicker.platform.getDirectoryPath();
|
||||
final folder = await FilePicker.getDirectoryPath();
|
||||
if (folder == null || folder.isEmpty) return;
|
||||
await _runAction(() => ref.read(extensionsControllerProvider.notifier).installFromUrl(folder, devInstall: true));
|
||||
}
|
||||
|
||||
@@ -1378,8 +1378,8 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
|
||||
initialValue: index == null ? '' : paths[index],
|
||||
pickPath: Util.isDesktop()
|
||||
? () async {
|
||||
final result = await FilePicker.platform.pickFiles();
|
||||
return result?.files.firstOrNull?.path;
|
||||
final file = await FilePicker.pickFile();
|
||||
return file?.path;
|
||||
}
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -763,15 +763,10 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
}
|
||||
|
||||
Future<void> _pickTorrentFile() async {
|
||||
final result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: const ['torrent'],
|
||||
withData: kIsWeb,
|
||||
);
|
||||
final file = result?.files.single;
|
||||
final file = await FilePicker.pickFile(type: FileType.custom, allowedExtensions: const ['torrent']);
|
||||
if (file == null) return;
|
||||
|
||||
await _applyTorrentFile(name: file.name, filePath: file.path, bytes: file.bytes);
|
||||
await _applyTorrentFile(name: file.name, filePath: file.path, readBytes: file.readAsBytes);
|
||||
}
|
||||
|
||||
Future<void> _handleDroppedTorrent(DropDoneDetails details) async {
|
||||
|
||||
@@ -109,7 +109,7 @@ class _TaskFileManagerViewState extends State<TaskFileManagerView> {
|
||||
try {
|
||||
final renderBox = actionContext.findRenderObject();
|
||||
final origin = renderBox is RenderBox ? renderBox.localToGlobal(Offset.zero) & renderBox.size : null;
|
||||
await Share.shareXFiles([XFile(_localPath(entry))], sharePositionOrigin: origin);
|
||||
await SharePlus.instance.share(ShareParams(files: [XFile(_localPath(entry))], sharePositionOrigin: origin));
|
||||
} catch (error) {
|
||||
if (mounted) showAppToast(context, error.toString(), type: AppToastType.error);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class DownloadDirectoryPicker {
|
||||
return _pickAndroid(context, currentPath: currentPath);
|
||||
}
|
||||
if (_platform == TargetPlatform.iOS) return null;
|
||||
return FilePicker.platform.getDirectoryPath();
|
||||
return FilePicker.getDirectoryPath();
|
||||
}
|
||||
|
||||
static Future<String?> _pickAndroid(BuildContext context, {required String currentPath}) async {
|
||||
|
||||
@@ -251,7 +251,7 @@ Future<String?> _getManifestPath(Browser browser) async {
|
||||
|
||||
Future<bool> _checkWindowsRegistry(String keyPath) async {
|
||||
try {
|
||||
final key = Registry.openPath(RegistryHive.localMachine, path: keyPath);
|
||||
final key = LOCAL_MACHINE.open(keyPath);
|
||||
key.close();
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
||||
@@ -26,7 +26,7 @@ void doRegisterUrlScheme(String scheme) {
|
||||
|
||||
void doUnregisterUrlScheme(String scheme) {
|
||||
if (Util.isWindows()) {
|
||||
Registry.currentUser.deleteKey('Software\\Classes\\$scheme', recursive: true);
|
||||
CURRENT_USER.removeSubkey('Software\\Classes\\$scheme');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ void doUnregisterDefaultTorrentClient() {
|
||||
if (Util.isWindows()) {
|
||||
doUnregisterUrlScheme("magnet");
|
||||
|
||||
Registry.currentUser.deleteKey(_torrentRegKey, recursive: true);
|
||||
Registry.currentUser.deleteKey(_torrentAppRegKey, recursive: true);
|
||||
CURRENT_USER.removeSubkey(_torrentRegKey);
|
||||
CURRENT_USER.removeSubkey(_torrentAppRegKey);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,14 @@ import 'package:win32_registry/win32_registry.dart';
|
||||
/// Check registry key
|
||||
/// If the key does not exist or the value is different, return false
|
||||
bool checkRegistry(String keyPath, String valueName, String value) {
|
||||
RegistryKey regKey;
|
||||
RegistryKey? regKey;
|
||||
try {
|
||||
regKey = Registry.openPath(RegistryHive.currentUser, path: keyPath);
|
||||
return regKey.getValueAsString(valueName) == value;
|
||||
regKey = CURRENT_USER.open(keyPath);
|
||||
return regKey.getString(valueName) == value;
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
regKey?.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +18,15 @@ bool checkRegistry(String keyPath, String valueName, String value) {
|
||||
/// If the key does not exist, create it
|
||||
/// If the value does not exist or is different, update it
|
||||
void upsertRegistry(String keyPath, String valueName, String value) {
|
||||
RegistryKey regKey;
|
||||
final regKey = CURRENT_USER.create(
|
||||
keyPath,
|
||||
config: const RegistryOpenConfig(access: RegistryAccess.all, create: true),
|
||||
);
|
||||
try {
|
||||
regKey = Registry.openPath(RegistryHive.currentUser, path: keyPath, desiredAccessRights: AccessRights.allAccess);
|
||||
} catch (e) {
|
||||
regKey = Registry.currentUser.createKey(keyPath);
|
||||
if (regKey.getString(valueName) != value) {
|
||||
regKey.setValue(valueName, RegistryValue.string(value));
|
||||
}
|
||||
} finally {
|
||||
regKey.close();
|
||||
}
|
||||
|
||||
if (regKey.getValueAsString(valueName) != value) {
|
||||
regKey.createValue(RegistryValue(valueName, RegistryValueType.string, value));
|
||||
}
|
||||
regKey.close();
|
||||
}
|
||||
Reference in new issue
Block a user