From 6a0db022302559f6ddd4d7deadffeddd920d2963 Mon Sep 17 00:00:00 2001 From: 21pages Date: Tue, 7 Nov 2023 09:09:05 +0800 Subject: [PATCH 1/2] closeAllSubWindow before install Signed-off-by: 21pages --- .../lib/desktop/pages/desktop_home_page.dart | 194 ++++++++++-------- 1 file changed, 104 insertions(+), 90 deletions(-) diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 59118f7cd..25670e628 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -336,11 +336,17 @@ class _DesktopHomePageState extends State } if (Platform.isWindows) { if (!bind.mainIsInstalled()) { - return buildInstallCard( - "", "install_tip", "Install", bind.mainGotoInstall); + return buildInstallCard("", "install_tip", "Install", () async { + await rustDeskWinManager.closeAllSubWindows(); + bind.mainGotoInstall(); + }); } else if (bind.mainIsInstalledLowerVersion()) { - return buildInstallCard("Status", "Your installation is lower version.", - "Click to upgrade", bind.mainUpdateMe); + return buildInstallCard( + "Status", "Your installation is lower version.", "Click to upgrade", + () async { + await rustDeskWinManager.closeAllSubWindows(); + bind.mainUpdateMe(); + }); } } else if (Platform.isMacOS) { if (!bind.mainIsCanScreenRecording(prompt: false)) { @@ -384,13 +390,16 @@ class _DesktopHomePageState extends State final keyShowSelinuxHelpTip = "show-selinux-help-tip"; if (bind.mainGetLocalOption(key: keyShowSelinuxHelpTip) != 'N') { LinuxCards.add(buildInstallCard( - "Warning", "selinux_tip", "", () async {}, - marginTop: LinuxCards.isEmpty ? 20.0 : 5.0, - help: 'Help', - link: - 'https://rustdesk.com/docs/en/client/linux/#permissions-issue', - closeButton: true, - closeOption: keyShowSelinuxHelpTip, + "Warning", + "selinux_tip", + "", + () async {}, + marginTop: LinuxCards.isEmpty ? 20.0 : 5.0, + help: 'Help', + link: + 'https://rustdesk.com/docs/en/client/linux/#permissions-issue', + closeButton: true, + closeOption: keyShowSelinuxHelpTip, )); } } @@ -418,7 +427,11 @@ class _DesktopHomePageState extends State Widget buildInstallCard(String title, String content, String btnText, GestureTapCallback onPressed, - {double marginTop = 20.0, String? help, String? link, bool? closeButton, String? closeOption}) { + {double marginTop = 20.0, + String? help, + String? link, + bool? closeButton, + String? closeOption}) { void closeCard() async { if (closeOption != null) { await bind.mainSetLocalOption(key: closeOption, value: 'N'); @@ -439,89 +452,90 @@ class _DesktopHomePageState extends State Container( margin: EdgeInsets.only(top: marginTop), child: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [ - Color.fromARGB(255, 226, 66, 188), - Color.fromARGB(255, 244, 114, 124), - ], - )), - padding: EdgeInsets.all(20), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: (title.isNotEmpty - ? [ - Center( - child: Text( - translate(title), - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ).marginOnly(bottom: 6)), - ] - : []) + - [ - Text( - translate(content), - style: TextStyle( - height: 1.5, - color: Colors.white, - fontWeight: FontWeight.normal, - fontSize: 13), - ).marginOnly(bottom: 20) - ] + - (btnText.isNotEmpty - ? [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - FixedWidthButton( - width: 150, - padding: 8, - isOutline: true, - text: translate(btnText), - textColor: Colors.white, - borderColor: Colors.white, - textSize: 20, - radius: 10, - onTap: onPressed, - ) - ]) - ] - : []) + - (help != null - ? [ - Center( - child: InkWell( - onTap: () async => - await launchUrl(Uri.parse(link!)), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color.fromARGB(255, 226, 66, 188), + Color.fromARGB(255, 244, 114, 124), + ], + )), + padding: EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: (title.isNotEmpty + ? [ + Center( child: Text( - translate(help), - style: TextStyle( - decoration: TextDecoration.underline, - color: Colors.white, - fontSize: 12), - )).marginOnly(top: 6)), - ] - : []))), + translate(title), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), + ).marginOnly(bottom: 6)), + ] + : []) + + [ + Text( + translate(content), + style: TextStyle( + height: 1.5, + color: Colors.white, + fontWeight: FontWeight.normal, + fontSize: 13), + ).marginOnly(bottom: 20) + ] + + (btnText.isNotEmpty + ? [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + FixedWidthButton( + width: 150, + padding: 8, + isOutline: true, + text: translate(btnText), + textColor: Colors.white, + borderColor: Colors.white, + textSize: 20, + radius: 10, + onTap: onPressed, + ) + ]) + ] + : []) + + (help != null + ? [ + Center( + child: InkWell( + onTap: () async => + await launchUrl(Uri.parse(link!)), + child: Text( + translate(help), + style: TextStyle( + decoration: + TextDecoration.underline, + color: Colors.white, + fontSize: 12), + )).marginOnly(top: 6)), + ] + : []))), ), if (closeButton != null && closeButton == true) - Positioned( - top: 18, - right: 0, - child: IconButton( - icon: Icon( - Icons.close, - color: Colors.white, - size: 20, + Positioned( + top: 18, + right: 0, + child: IconButton( + icon: Icon( + Icons.close, + color: Colors.white, + size: 20, + ), + onPressed: closeCard, ), - onPressed: closeCard, ), - ), ], ); } From f2d345e7b10c0d5551d8f72895beb04840aeb93e Mon Sep 17 00:00:00 2001 From: 21pages Date: Tue, 7 Nov 2023 10:16:01 +0800 Subject: [PATCH 2/2] fix missing log when removed directory names have same prefix Signed-off-by: 21pages --- flutter/lib/models/cm_file_model.dart | 13 ++++++++++--- src/server/connection.rs | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/flutter/lib/models/cm_file_model.dart b/flutter/lib/models/cm_file_model.dart index ebb0d6f7f..ce9b711a2 100644 --- a/flutter/lib/models/cm_file_model.dart +++ b/flutter/lib/models/cm_file_model.dart @@ -123,14 +123,21 @@ class CmFileModel { } int removeUnreadCount = 0; if (data.dir) { + bool isChild(String parent, String child) { + if (child.startsWith(parent) && child.length > parent.length) { + final suffix = child.substring(parent.length); + return suffix.startsWith('/') || suffix.startsWith('\\'); + } + return false; + } + removeUnreadCount = jobTable .where((e) => e.action == CmFileAction.remove && - e.fileName.startsWith(data.path)) + isChild(data.path, e.fileName)) .length; jobTable.removeWhere((e) => - e.action == CmFileAction.remove && - e.fileName.startsWith(data.path)); + e.action == CmFileAction.remove && isChild(data.path, e.fileName)); } jobTable.add(CmFileLog() ..id = data.id diff --git a/src/server/connection.rs b/src/server/connection.rs index 842359b51..2b0829035 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -49,6 +49,7 @@ use sha2::{Digest, Sha256}; use std::sync::atomic::Ordering; use std::{ num::NonZeroI64, + path::PathBuf, sync::{atomic::AtomicI64, mpsc as std_mpsc}, }; #[cfg(not(any(target_os = "android", target_os = "ios")))] @@ -2953,12 +2954,17 @@ impl FileRemoveLogControl { fn on_remove_dir(&mut self, d: FileRemoveDir) -> Option { self.instant = Instant::now(); - self.removed_files.retain(|f| !f.path.starts_with(&d.path)); - self.removed_dirs.retain(|x| !x.path.starts_with(&d.path)); + let direct_child = |parent: &str, child: &str| { + PathBuf::from(child).parent().map(|x| x.to_path_buf()) == Some(PathBuf::from(parent)) + }; + self.removed_files + .retain(|f| !direct_child(&f.path, &d.path)); + self.removed_dirs + .retain(|x| !direct_child(&d.path, &x.path)); if !self .removed_dirs .iter() - .any(|x| d.path.starts_with(&x.path)) + .any(|x| direct_child(&x.path, &d.path)) { self.removed_dirs.push(d.clone()); }