π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Avoid scanning upload history for cache refresh
Neeraj Guptae7a7da34702d
diff --git a/mobile/apps/photos/lib/module/upload/service/file_uploader.dart b/mobile/apps/photos/lib/module/upload/service/file_uploader.dartindex 69e769f99d..8d47c5dd31 100644--- a/mobile/apps/photos/lib/module/upload/service/file_uploader.dart+++ b/mobile/apps/photos/lib/module/upload/service/file_uploader.dart@@ -78,6 +78,9 @@ class FileUploader {/// Returns true if any file uploads are currently in progressbool get isUploading => _uploadCounter > 0;+ /// Returns true if an upload is queued, running, or waiting in background.+ bool get hasPendingUploads => _queue.isNotEmpty;+// Maintains the count of files in the current upload session.// Upload session is the period between the first entry into the _queue and last entry out of the _queueint _totalCountInUploadSession = 0;diff --git a/mobile/apps/photos/lib/services/magic_cache_service.dart b/mobile/apps/photos/lib/services/magic_cache_service.dartindex 360e07854e..f10ff280ad 100644--- a/mobile/apps/photos/lib/services/magic_cache_service.dart+++ b/mobile/apps/photos/lib/services/magic_cache_service.dart@@ -10,13 +10,11 @@ import "package:logging/logging.dart";import "package:path_provider/path_provider.dart";import "package:photos/core/event_bus.dart";import "package:photos/db/offline_files_db.dart";-import "package:photos/events/backup_updated_event.dart";import "package:photos/events/file_uploaded_event.dart";import "package:photos/events/magic_cache_updated_event.dart";import "package:photos/events/tab_changed_event.dart";import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";-import "package:photos/models/backup/backup_item_status.dart";import "package:photos/models/file/extensions/file_props.dart";import "package:photos/models/file/file.dart";import "package:photos/models/ml/discover/prompt.dart";@@ -24,6 +22,7 @@ import "package:photos/models/search/generic_search_result.dart";import "package:photos/models/search/hierarchical/hierarchical_search_filter.dart";import "package:photos/models/search/hierarchical/magic_filter.dart";import "package:photos/models/search/search_types.dart";+import "package:photos/module/upload/service/file_uploader.dart";import "package:photos/service_locator.dart";import "package:photos/services/machine_learning/semantic_search/semantic_search_service.dart";import "package:photos/services/search_service.dart";@@ -250,7 +249,6 @@ class MagicCacheService {int _cacheGeneration = 0;Timer? _backgroundUpdateTimer;bool _refreshWhenCurrentUpdateCompletes = false;- bool _uploadsActive = false;MagicCacheService(this._prefs) {_logger.info("MagicCacheService constructor");@@ -258,14 +256,6 @@ class MagicCacheService {queueUpdate("File uploaded");_scheduleBackgroundUpdate();});- Bus.instance.on<BackupUpdatedEvent>().listen((event) {- _uploadsActive = event.items.values.any(- (item) =>- item.status == BackupItemStatus.inQueue ||- item.status == BackupItemStatus.uploading ||- item.status == BackupItemStatus.inBackground,- );- });Bus.instance.on<TabChangedEvent>().listen((event) {if (event.source == TabChangedEventSource.pageView &&event.selectedIndex == _kSearchTabIndex) {@@ -352,7 +342,7 @@ class MagicCacheService {_pendingUpdateReason.add("Forced update");}await _updateCacheIfTheTimeHasCome();- if (_uploadsActive && !forced && !interactive) {+ if (FileUploader.instance.hasPendingUploads && !forced && !interactive) {_scheduleBackgroundUpdate();return;}