diff --git a/lib/services/remote_sync_service.dart b/lib/services/remote_sync_service.dart index 6bc5f20b1..3da84cd86 100644 --- a/lib/services/remote_sync_service.dart +++ b/lib/services/remote_sync_service.dart @@ -347,18 +347,23 @@ class RemoteSyncService { 2) Delete files who localIDs is also present in other collections. 3) For Remaining files, set the collectionID as -1 */ - debugPrint("Removing files for collections $collectionIDs"); + _logger.info("Removing files for collections $collectionIDs"); for (int collectionID in collectionIDs) { final List pendingUploads = await _db.getPendingUploadForCollection(collectionID); if (pendingUploads.isEmpty) { continue; + } else { + _logger.info("RemovingFiles $collectionIDs: pendingUploads " + "${pendingUploads.length}"); } final Set localIDsInOtherFileEntries = await _db.getLocalIDsPresentInEntries( pendingUploads, collectionID, ); + _logger.info("RemovingFiles $collectionIDs: filesInOtherCollection " + "${localIDsInOtherFileEntries.length}"); final List entriesToUpdate = []; final List entriesToDelete = []; for (File pendingUpload in pendingUploads) { @@ -371,6 +376,10 @@ class RemoteSyncService { } await _db.deleteMultipleByGeneratedIDs(entriesToDelete); await _db.insertMultiple(entriesToUpdate); + _logger.info( + "RemovingFiles $collectionIDs: deleted " + "${entriesToDelete.length} and updated ${entriesToUpdate.length}", + ); } } diff --git a/lib/ui/backup_folder_selection_page.dart b/lib/ui/backup_folder_selection_page.dart index 13685a057..7f7819dad 100644 --- a/lib/ui/backup_folder_selection_page.dart +++ b/lib/ui/backup_folder_selection_page.dart @@ -17,6 +17,7 @@ import 'package:photos/models/file.dart'; import 'package:photos/services/remote_sync_service.dart'; import 'package:photos/ui/common/loading_widget.dart'; import 'package:photos/ui/viewer/file/thumbnail_widget.dart'; +import 'package:photos/utils/dialog_util.dart'; class BackupFolderSelectionPage extends StatefulWidget { final bool isOnboarding; @@ -175,23 +176,7 @@ class _BackupFolderSelectionPageState extends State { onPressed: _selectedDevicePathIDs.isEmpty ? null : () async { - final Map syncStatus = {}; - for (String pathID in _allDevicePathIDs) { - syncStatus[pathID] = - _selectedDevicePathIDs.contains(pathID); - } - await Configuration.instance - .setHasSelectedAnyBackupFolder( - _selectedDevicePathIDs.isNotEmpty, - ); - await RemoteSyncService.instance - .updateDeviceFolderSyncStatus(syncStatus); - await Configuration.instance - .setSelectAllFoldersForBackup( - _allDevicePathIDs.length == - _selectedDevicePathIDs.length, - ); - Navigator.of(context).pop(); + await updateFolderSettings(); }, child: Text(widget.buttonText), ), @@ -223,6 +208,33 @@ class _BackupFolderSelectionPageState extends State { ); } + Future updateFolderSettings() async { + final dialog = createProgressDialog( + context, + "Updating folder selection...", + ); + await dialog.show(); + try { + final Map syncStatus = {}; + for (String pathID in _allDevicePathIDs) { + syncStatus[pathID] = _selectedDevicePathIDs.contains(pathID); + } + await Configuration.instance.setHasSelectedAnyBackupFolder( + _selectedDevicePathIDs.isNotEmpty, + ); + await Configuration.instance.setSelectAllFoldersForBackup( + _allDevicePathIDs.length == _selectedDevicePathIDs.length, + ); + await RemoteSyncService.instance.updateDeviceFolderSyncStatus(syncStatus); + dialog.hide(); + Navigator.of(context).pop(); + } catch (e, s) { + _logger.severe("Failed to updated backup folder", e, s); + await dialog.hide(); + showGenericErrorDialog(context); + } + } + Widget _getFolders() { if (_deviceCollections == null) { return const EnteLoadingWidget(); diff --git a/lib/utils/file_uploader.dart b/lib/utils/file_uploader.dart index 8ebc4a42f..b69f8c5c0 100644 --- a/lib/utils/file_uploader.dart +++ b/lib/utils/file_uploader.dart @@ -186,6 +186,7 @@ class FileUploader { for (final id in uploadsToBeRemoved) { _queue.remove(id).completer.completeError(reason); } + _logger.info('number of enteries removed from queue ${uploadsToBeRemoved.length}'); _totalCountInUploadSession -= uploadsToBeRemoved.length; }