Skip to content

armgit / ente

Public Imported from GitHub
0

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

Adjust remote sync background checks

Prateek Sunal476f1af71c47
diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
index 429a14df44..8709db804f 100644
--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
@@ -122,12 +122,15 @@ class RemoteSyncService {
);
try {
+ final canPrepareUploadsInBackground =
+ !isProcessBg || await canUseHighBandwidth();
+
// use flag to decide if we should start marking files for upload before
// remote-sync is done. This is done to avoid adding existing files to
// the same or different collection when user had already uploaded them
// before.
final bool hasSyncedBefore = _prefs.containsKey(_isFirstRemoteSyncDone);
- if (hasSyncedBefore) {
+ if (hasSyncedBefore && canPrepareUploadsInBackground) {
await syncDeviceCollectionFilesForUpload();
}
await _pullDiff();
@@ -143,7 +146,9 @@ class RemoteSyncService {
if (!hasSyncedBefore) {
await _prefs.setBool(_isFirstRemoteSyncDone, true);
- await syncDeviceCollectionFilesForUpload();
+ if (canPrepareUploadsInBackground) {
+ await syncDeviceCollectionFilesForUpload();
+ }
}
if (
@@ -152,7 +157,7 @@ class RemoteSyncService {
fileDataService.syncFDStatus().ignore();
}
- if (isProcessBg && !await canUseHighBandwidth()) {
+ if (!canPrepareUploadsInBackground) {
throw WiFiUnavailableError();
}