diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 0fdc3d83..c125915b 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -470,7 +470,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -478,7 +478,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -602,7 +602,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -610,7 +610,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -628,7 +628,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -636,7 +636,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -657,7 +657,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -670,7 +670,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -696,7 +696,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -709,7 +709,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -732,7 +732,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -745,7 +745,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/lib/core/update.dart b/lib/core/update.dart index 933fb683..033ff181 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -6,10 +6,8 @@ import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:logging/logging.dart'; import 'package:r_upgrade/r_upgrade.dart'; import 'package:toolbox/core/extension/context.dart'; -import 'package:toolbox/core/utils/misc.dart' hide pathJoin; import 'package:toolbox/data/model/app/update.dart'; import 'package:toolbox/data/res/path.dart'; -import 'package:toolbox/data/res/ui.dart'; import '../data/provider/app.dart'; import '../data/res/build_data.dart'; @@ -88,55 +86,16 @@ Future doUpdate(BuildContext context, {bool force = false}) async { } Future _doUpdate(AppUpdate update, BuildContext context, S s) async { + final url = update.url.current; + if (url == null) return; + if (isAndroid) { - final url = update.url.current; - if (url == null) return; final fileName = url.split('/').last; - final id = await RUpgrade.upgrade( - url, - fileName: fileName, - isAutoRequestInstall: false, - ); - RUpgrade.stream.listen((event) async { - if (event.status?.value == 3) { - if (id == null) { - showSnackBar(context, const Text('install id is null')); - return; - } - final sha256 = () { - try { - return fileName.split('.').first; - } catch (e) { - _logger.warning('sha256 parse failed: $e'); - return null; - } - }(); - final dlPath = pathJoin(await _dlDir, fileName); - final computed = await getFileSha256(dlPath); - if (computed != sha256) { - _logger.info('Mismatch sha256: $computed, $sha256'); - final resume = await showRoundDialog( - context: context, - title: Text(s.attention), - child: const Text('sha256 is null'), - actions: [ - TextButton( - onPressed: () => context.pop(false), - child: Text(s.cancel), - ), - TextButton( - onPressed: () => context.pop(true), - child: Text(s.ok, style: textRed), - ), - ], - ); - if (!resume) return; - } - RUpgrade.install(id); - } - }); + await RUpgrade.upgrade(url, fileName: fileName); } else if (isIOS) { await RUpgrade.upgradeFromAppStore('1586449703'); + } else if (isMacOS) { + await openUrl(url); } else { showRoundDialog( context: context, @@ -160,4 +119,4 @@ Future _rmDownloadApks() async { } } -Future get _dlDir async => pathJoin((await docDir).path, 'Download'); +Future get _dlDir async => joinPath((await docDir).path, 'Download'); diff --git a/lib/core/utils/platform.dart b/lib/core/utils/platform.dart index 88e79004..cb920197 100644 --- a/lib/core/utils/platform.dart +++ b/lib/core/utils/platform.dart @@ -38,12 +38,7 @@ final _p = () { return PlatformType.unknown; }(); -final _pathSep = () { - if (Platform.isWindows) { - return '\\'; - } - return '/'; -}(); +final _pathSep = Platform.pathSeparator; PlatformType get platform => _p; String get pathSeparator => _pathSep; @@ -73,7 +68,7 @@ String? getHomeDir() { } /// Join two paths with platform specific separator -String pathJoin(String path1, String path2) { +String joinPath(String path1, String path2) { if (isWindows) { return path1 + (path1.endsWith('\\') ? '' : '\\') + path2; } diff --git a/lib/data/model/app/path_with_prefix.dart b/lib/data/model/app/path_with_prefix.dart index 6f195eba..ada3371e 100644 --- a/lib/data/model/app/path_with_prefix.dart +++ b/lib/data/model/app/path_with_prefix.dart @@ -1,12 +1,14 @@ import '../../../core/utils/platform.dart'; -class PathWithPrefix { +/// It's used on platform's file system. +/// So use [Platform.pathSeparator] to join path. +class LocalPath { final String _prefixPath; String _path = '/'; String? _prePath; String get path => _prefixPath + _path; - PathWithPrefix(String prefixPath) : _prefixPath = _trimSuffix(prefixPath); + LocalPath(String prefixPath) : _prefixPath = _trimSuffix(prefixPath); void update(String newPath) { _prePath = _path; @@ -21,7 +23,7 @@ class PathWithPrefix { _path = '/'; return; } - _path = pathJoin(_path, newPath); + _path = joinPath(_path, newPath); } bool get canBack => path != '$_prefixPath/'; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 515d1ce7..878181c8 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 510; + static const int build = 515; static const String engine = "3.13.1"; - static const String buildAt = "2023-08-29 10:32:08.906333"; - static const int modifications = 4; + static const String buildAt = "2023-08-30 16:31:26.338447"; + static const int modifications = 3; } diff --git a/lib/view/page/private_key/list.dart b/lib/view/page/private_key/list.dart index a91d5a9b..3201cef4 100644 --- a/lib/view/page/private_key/list.dart +++ b/lib/view/page/private_key/list.dart @@ -82,7 +82,7 @@ class _PrivateKeyListState extends State if (isDesktop && store.box.keys.isEmpty) { final home = getHomeDir(); if (home == null) return; - final idRsaFile = File(pathJoin(home, '.ssh/id_rsa')); + final idRsaFile = File(joinPath(home, '.ssh/id_rsa')); if (!idRsaFile.existsSync()) return; final sysPk = PrivateKeyInfo( id: 'system', diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index f362b812..d9f0d11a 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -7,7 +7,7 @@ import 'package:provider/provider.dart'; import 'package:toolbox/core/extension/media_queryx.dart'; import '../../../core/route.dart'; -import '../../../core/utils/misc.dart' hide pathJoin; +import '../../../core/utils/misc.dart'; import '../../../core/utils/platform.dart'; import '../../../core/utils/ui.dart'; import '../../../data/model/app/net_view.dart'; diff --git a/lib/view/page/storage/local.dart b/lib/view/page/storage/local.dart index 3f6fb436..d4e8cfd4 100644 --- a/lib/view/page/storage/local.dart +++ b/lib/view/page/storage/local.dart @@ -37,7 +37,7 @@ class LocalStoragePage extends StatefulWidget { } class _LocalStoragePageState extends State { - PathWithPrefix? _path; + LocalPath? _path; late S _s; @override @@ -45,12 +45,12 @@ class _LocalStoragePageState extends State { super.initState(); if (widget.initDir != null) { setState(() { - _path = PathWithPrefix(widget.initDir!); + _path = LocalPath(widget.initDir!); }); } else { sftpDir.then((dir) { setState(() { - _path = PathWithPrefix(dir.path); + _path = LocalPath(dir.path); }); }); } diff --git a/lib/view/page/storage/sftp.dart b/lib/view/page/storage/sftp.dart index 37c5f331..bcc683db 100644 --- a/lib/view/page/storage/sftp.dart +++ b/lib/view/page/storage/sftp.dart @@ -15,7 +15,7 @@ import '../../../core/extension/numx.dart'; import '../../../core/extension/stringx.dart'; import '../../../core/route.dart'; import '../../../core/utils/misc.dart'; -import '../../../core/utils/platform.dart' hide pathJoin; +import '../../../core/utils/platform.dart'; import '../../../core/utils/ui.dart'; import '../../../data/model/server/server_private_info.dart'; import '../../../data/model/sftp/absolute_path.dart'; diff --git a/lib/view/widget/server_func_btns.dart b/lib/view/widget/server_func_btns.dart index bda49855..e8ec0439 100644 --- a/lib/view/widget/server_func_btns.dart +++ b/lib/view/widget/server_func_btns.dart @@ -2,16 +2,16 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:toolbox/data/provider/server.dart'; import '../../core/route.dart'; -import '../../core/utils/misc.dart' hide pathJoin; +import '../../core/utils/misc.dart'; import '../../core/utils/platform.dart'; import '../../core/utils/server.dart'; import '../../core/utils/ui.dart'; import '../../data/model/app/menu.dart'; import '../../data/model/server/server_private_info.dart'; import '../../data/model/server/snippet.dart'; +import '../../data/provider/server.dart'; import '../../data/provider/snippet.dart'; import '../../locator.dart'; import 'popup_menu.dart'; @@ -161,7 +161,7 @@ Future _gotoSSH( final path = () { final tempKeyFileName = 'srvbox_pk_${spi.pubKeyId}'; - return pathJoin(Directory.systemTemp.path, tempKeyFileName); + return joinPath(Directory.systemTemp.path, tempKeyFileName); }(); final file = File(path); final shouldGenKey = spi.pubKeyId != null; diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index e87954ed..e0bddf1b 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -474,9 +474,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -489,9 +489,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -504,9 +504,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 510; + CURRENT_PROJECT_VERSION = 515; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.510; + MARKETING_VERSION = 1.0.515; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;