From 177d3c51fb1a8352304ec7eb9823f6dfb3c039b1 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sun, 25 Feb 2024 12:22:58 +0800 Subject: [PATCH] Don't reload files if nothing changes in remote sync --- app/lib/controller/files_controller.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/lib/controller/files_controller.dart b/app/lib/controller/files_controller.dart index 64357591..a64ec4d1 100644 --- a/app/lib/controller/files_controller.dart +++ b/app/lib/controller/files_controller.dart @@ -90,9 +90,10 @@ class FilesController { _c.touchManager.clearTouchCache(); final progress = IntProgress(account.roots.length); + var hasChange = false; for (final r in account.roots) { final dirPath = file_util.unstripPath(account, r); - await SyncDir(_c)( + hasChange |= await SyncDir(_c)( account, dirPath, onProgressUpdate: (value) { @@ -107,10 +108,13 @@ class FilesController { if (!isShareDirIncluded) { _log.info("[syncRemote] Explicitly scanning share folder"); - await SyncDir(_c)(account, shareDir.path, isRecursive: false); + hasChange |= + await SyncDir(_c)(account, shareDir.path, isRecursive: false); + } + if (hasChange) { + // load the synced content to stream + unawaited(_reload()); } - // load the synced content to stream - unawaited(_reload()); } finally { _isSyncing = false; }