Show progress dialog on folder selection update
This commit is contained in:
parent
40f7ee6ec5
commit
a2603a7dd9
3 changed files with 40 additions and 18 deletions
|
@ -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<File> pendingUploads =
|
||||
await _db.getPendingUploadForCollection(collectionID);
|
||||
if (pendingUploads.isEmpty) {
|
||||
continue;
|
||||
} else {
|
||||
_logger.info("RemovingFiles $collectionIDs: pendingUploads "
|
||||
"${pendingUploads.length}");
|
||||
}
|
||||
final Set<String> localIDsInOtherFileEntries =
|
||||
await _db.getLocalIDsPresentInEntries(
|
||||
pendingUploads,
|
||||
collectionID,
|
||||
);
|
||||
_logger.info("RemovingFiles $collectionIDs: filesInOtherCollection "
|
||||
"${localIDsInOtherFileEntries.length}");
|
||||
final List<File> entriesToUpdate = [];
|
||||
final List<int> 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}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<BackupFolderSelectionPage> {
|
|||
onPressed: _selectedDevicePathIDs.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
final Map<String, bool> 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<BackupFolderSelectionPage> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> updateFolderSettings() async {
|
||||
final dialog = createProgressDialog(
|
||||
context,
|
||||
"Updating folder selection...",
|
||||
);
|
||||
await dialog.show();
|
||||
try {
|
||||
final Map<String, bool> 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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue