Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Allow manual upload of videos when global video upload is disabled

Neeraj Gupta7cec46ef3d61
diff --git a/mobile/lib/services/remote_sync_service.dart b/mobile/lib/services/remote_sync_service.dart
index 0144d70e65..4c52227581 100644
--- a/mobile/lib/services/remote_sync_service.dart
+++ b/mobile/lib/services/remote_sync_service.dart
@@ -52,6 +52,15 @@ class RemoteSyncService {
bool _isExistingSyncSilent = false;
static const kHasSyncedArchiveKey = "has_synced_archive";
+ /* This setting is used to maintain a list of local IDs for videos that the user has manually
+ marked for upload, even if the global video upload setting is currently disabled.
+ When the global video upload setting is disabled, we typically ignore all video uploads. However, for videos that have been added to this list, we
+ want to still allow them to be uploaded, despite the global setting being disabled.
+
+ This allows users to queue up videos for upload, and have them successfully upload
+ even if they later toggle the global video upload setting to disabled.
+ */
+ static const _ignoreBackUpSettingsForIDs_ = "ignoreBackUpSettingsForIDs";
final String _isFirstRemoteSyncDone = "isFirstRemoteSyncDone";
// 28 Sept, 2021 9:03:20 AM IST
@@ -189,6 +198,18 @@ class RemoteSyncService {
return _prefs.containsKey(_isFirstRemoteSyncDone);
}
+ Future<bool> whiteListVideoForUpload(EnteFile file) async {
+ if (file.fileType == FileType.video &&
+ !_config.shouldBackupVideos() &&
+ file.localID != null) {
+ final List<String> whitelistedIDs =
+ _prefs.getStringList(_ignoreBackUpSettingsForIDs_) ?? <String>[];
+ whitelistedIDs.add(file.localID!);
+ return _prefs.setStringList(_ignoreBackUpSettingsForIDs_, whitelistedIDs);
+ }
+ return false;
+ }
+
Future<void> _pullDiff() async {
_logger.info("Pulling remote diff");
final isFirstSync = !_collectionsService.hasSyncedCollections();
@@ -524,8 +545,13 @@ class RemoteSyncService {
final List<EnteFile> filesToBeUploaded = [];
int ignoredForUpload = 0;
int skippedVideos = 0;
+ final whitelistedIDs =
+ (_prefs.getStringList(_ignoreBackUpSettingsForIDs_) ?? <String>[])
+ .toSet();
for (var file in originalFiles) {
- if (shouldRemoveVideos && file.fileType == FileType.video) {
+ if (shouldRemoveVideos &&
+ (file.fileType == FileType.video &&
+ !whitelistedIDs.contains(file.localID))) {
skippedVideos++;
continue;
}
diff --git a/mobile/lib/ui/viewer/file_details/upload_icon_widget.dart b/mobile/lib/ui/viewer/file_details/upload_icon_widget.dart
index 1d724d4b75..a0cc47f787 100644
--- a/mobile/lib/ui/viewer/file_details/upload_icon_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/upload_icon_widget.dart
@@ -125,6 +125,8 @@ class _UpdateIconWidgetState extends State<UploadIconWidget> {
.id;
await FilesDB.instance.insert(widget.file);
}
+ await RemoteSyncService.instance
+ .whiteListVideoForUpload(widget.file);
RemoteSyncService.instance.sync().ignore();
if (mounted) {
setState(() {