diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 9e8e1365..3b989289 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 = 452; + CURRENT_PROJECT_VERSION = 453; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -478,7 +478,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.452; + MARKETING_VERSION = 1.0.453; 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 = 452; + CURRENT_PROJECT_VERSION = 453; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -610,7 +610,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.452; + MARKETING_VERSION = 1.0.453; 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 = 452; + CURRENT_PROJECT_VERSION = 453; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -636,7 +636,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.452; + MARKETING_VERSION = 1.0.453; 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 = 452; + CURRENT_PROJECT_VERSION = 453; 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.452; + MARKETING_VERSION = 1.0.453; 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 = 452; + CURRENT_PROJECT_VERSION = 453; 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.452; + MARKETING_VERSION = 1.0.453; 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 = 452; + CURRENT_PROJECT_VERSION = 453; 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.452; + MARKETING_VERSION = 1.0.453; 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 5733c8ae..549b77ea 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -18,7 +18,6 @@ import 'utils/platform.dart'; import 'utils/ui.dart'; final _logger = Logger('UPDATE'); -late final String _dlDir; Future isFileAvailable(String url) async { try { @@ -97,22 +96,44 @@ Future _doUpdate(AppUpdate update, BuildContext context, S s) async { fileName: fileName, isAutoRequestInstall: false, ); - if (id == null) { - showSnackBar(context, const Text('install id is null')); - return; - } - final sha256 = update.sha256.current; - if (sha256 == null) { - showSnackBar(context, const Text('sha256 is null')); - return; - } - final dlPath = pathJoin(_dlDir, fileName); - final computed = await getFileSha256(dlPath); - if (computed != sha256) { - showSnackBar(context, Text('Mismatch sha256: $computed, $sha256')); - return; - } - RUpgrade.install(id); + 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: const TextStyle(color: Colors.red)), + ), + ], + ); + if (!resume) return; + } + RUpgrade.install(id); + } + }); } else if (isIOS) { await RUpgrade.upgradeFromAppStore('1586449703'); } else { @@ -132,9 +153,10 @@ Future _doUpdate(AppUpdate update, BuildContext context, S s) async { // rmdir Download Future _rmDownloadApks() async { if (!isAndroid) return; - _dlDir = pathJoin((await docDir).path, 'Download'); - final dlDir = Directory(_dlDir); + final dlDir = Directory(await _dlDir); if (await dlDir.exists()) { await dlDir.delete(recursive: true); } } + +Future get _dlDir async => pathJoin((await docDir).path, 'Download'); diff --git a/lib/data/model/app/update.dart b/lib/data/model/app/update.dart index f087a92a..01a8d592 100644 --- a/lib/data/model/app/update.dart +++ b/lib/data/model/app/update.dart @@ -34,13 +34,11 @@ class AppUpdate { required this.changelog, required this.build, required this.url, - required this.sha256, }); final AppUpdatePlatformSpecific changelog; final Build build; final AppUpdatePlatformSpecific url; - final AppUpdatePlatformSpecific sha256; factory AppUpdate.fromRawJson(String str) => AppUpdate.fromJson(json.decode(str)); @@ -51,14 +49,12 @@ class AppUpdate { changelog: AppUpdatePlatformSpecific.fromJson(json["changelog"]), build: Build.fromJson(json["build"]), url: AppUpdatePlatformSpecific.fromJson(json["url"]), - sha256: AppUpdatePlatformSpecific.fromJson(json["sha256"]), ); Map toJson() => { "changelog": changelog.toJson(), "build": build.toJson(), "url": url.toJson(), - "sha256": sha256.toJson(), }; } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 84db99be..40ba6000 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 = 452; + static const int build = 453; static const String engine = "3.10.6"; - static const String buildAt = "2023-08-08 16:29:00.513310"; - static const int modifications = 11; + static const String buildAt = "2023-08-08 17:41:45.597966"; + static const int modifications = 1; } diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index afb0fb84..b080d446 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -149,10 +149,16 @@ class _ServerPageState extends State } return GestureDetector( key: Key(si.spi.id + (_tag ?? '')), - onTap: () => AppRoute( - ServerDetailPage(si.spi.id), - 'server detail page', - ).go(context), + onTap: () { + if (si.state == ServerState.connected) { + AppRoute( + ServerDetailPage(si.spi.id), + 'server detail page', + ).go(context); + } else { + _showFailReason(si.status); + } + }, child: RoundRectCard( Padding( padding: const EdgeInsets.all(13), @@ -260,19 +266,7 @@ class _ServerPageState extends State ); if (cs == ServerState.failed && ss.failedInfo != null) { return GestureDetector( - onTap: () => showRoundDialog( - context: context, - title: Text(_s.error), - child: SingleChildScrollView( - child: Text(ss.failedInfo!), - ), - actions: [ - TextButton( - onPressed: () => copy2Clipboard(ss.failedInfo!), - child: Text(_s.copy), - ) - ], - ), + onTap: () => _showFailReason(ss), child: Text( _s.viewErr, style: textSize12Grey, @@ -287,6 +281,22 @@ class _ServerPageState extends State ); } + void _showFailReason(ServerStatus ss) { + showRoundDialog( + context: context, + title: Text(_s.error), + child: SingleChildScrollView( + child: Text(ss.failedInfo!), + ), + actions: [ + TextButton( + onPressed: () => copy2Clipboard(ss.failedInfo!), + child: Text(_s.copy), + ) + ], + ); + } + Widget _buildSSHBtn(ServerPrivateInfo spi) { return GestureDetector( child: const Icon(Icons.terminal, size: 21), diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index d00a0ba6..82efc503 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -475,9 +475,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 452; + CURRENT_PROJECT_VERSION = 453; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.452; + MARKETING_VERSION = 1.0.453; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -490,9 +490,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 452; + CURRENT_PROJECT_VERSION = 453; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.452; + MARKETING_VERSION = 1.0.453; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -505,9 +505,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 452; + CURRENT_PROJECT_VERSION = 453; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.452; + MARKETING_VERSION = 1.0.453; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/make.dart b/make.dart index 94203414..862a7661 100755 --- a/make.dart +++ b/make.dart @@ -91,8 +91,8 @@ Future dartFormat() async { } } -Future getFileSha1(String path) async { - final result = await Process.run('shasum', ['-a', '1', path]); +Future getFileSha256(String path) async { + final result = await Process.run('shasum', ['-a', '256', path]); final stdout = result.stdout as String; return stdout.split(' ')[0]; } @@ -142,11 +142,11 @@ Future flutterBuildAndroid() async { } Future scp2CDN() async { - final sha1 = await getFileSha1(apkPath); - print('SHA1: $sha1'); + final sha256 = await getFileSha256(apkPath); + print('SHA256: $sha256'); final result = await Process.run( 'scp', - [apkPath, 'hk:/var/www/res/serverbox/apks/$build.apk'], + [apkPath, 'hk:/var/www/res/serverbox/$sha256.apk'], runInShell: true, ); if (result.exitCode != 0) {