Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Gate sync diagnostics behind flag

Prateek Sunal6b8cdc293ed7
diff --git a/mobile/apps/photos/lib/services/sync/local_sync_service.dart b/mobile/apps/photos/lib/services/sync/local_sync_service.dart
index deeb5fc3c8..1c48c31272 100644
--- a/mobile/apps/photos/lib/services/sync/local_sync_service.dart
+++ b/mobile/apps/photos/lib/services/sync/local_sync_service.dart
@@ -238,7 +238,7 @@ class LocalSyncService {
),
);
}
- if (flagService.internalUser) {
+ if (flagService.syncRecoveryDiagnostics) {
final int newMappingCount =
localDiffResult.newPathToLocalIDs?.values.fold<int>(
0,
@@ -330,7 +330,7 @@ class LocalSyncService {
required int fromTime,
required int toTime,
}) async {
- final bool isInternalUser = flagService.internalUser;
+ final bool shouldLogSyncRecovery = flagService.syncRecoveryDiagnostics;
final Tuple2<List<LocalPathAsset>, List<EnteFile>> result =
await getLocalPathAssetsAndFiles(fromTime, toTime);
@@ -361,7 +361,7 @@ class LocalSyncService {
conflictAlgorithm: SqliteAsyncConflictAlgorithm.ignore,
);
_logger.info('Inserted ${files.length} out of ${allFiles.length} files');
- if (isInternalUser && allFiles.length != files.length) {
+ if (shouldLogSyncRecovery && allFiles.length != files.length) {
final sampleLocalIDs =
allFiles.take(3).map((file) => file.localID).toList();
_logger.internalInfo(
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 d05485af30..5a5608fa51 100644
--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
@@ -379,7 +379,7 @@ class RemoteSyncService {
Future<void> syncDeviceCollectionFilesForUpload() async {
_logger.info("Syncing device collections to be uploaded");
final int ownerID = _config.getUserID()!;
- final bool isInternalUser = flagService.internalUser;
+ final bool shouldLogSyncRecovery = flagService.syncRecoveryDiagnostics;
final deviceCollections = await _db.getDeviceCollections();
deviceCollections.removeWhere((element) => !element.shouldBackup);
@@ -405,7 +405,7 @@ class RemoteSyncService {
for (final deviceCollection in deviceCollections) {
final Set<String> localIDsToSync =
pathIdToLocalIDs[deviceCollection.id]?.toSet() ?? {};
- final int mappedCount = isInternalUser ? localIDsToSync.length : 0;
+ final int mappedCount = shouldLogSyncRecovery ? localIDsToSync.length : 0;
if (deviceCollection.uploadStrategy == UploadStrategy.ifMissing) {
final Set<String> alreadyClaimedLocalIDs =
await _db.getLocalIDsMarkedForOrAlreadyUploaded(ownerID);
@@ -426,7 +426,7 @@ class RemoteSyncService {
}
if (localIDsToSync.isEmpty) {
- if (isInternalUser && mappedCount == 0) {
+ if (shouldLogSyncRecovery && mappedCount == 0) {
_logger.internalInfo(
"[${deviceCollection.name}] upload-prep empty: "
"pathID=${deviceCollection.id} mappedFromPath=0",
@@ -465,7 +465,8 @@ class RemoteSyncService {
// new file entries, where we can store mapping for localID and
// corresponding collection ID
if (localIDsToSync.isNotEmpty) {
- final int postFilterCount = isInternalUser ? localIDsToSync.length : 0;
+ final int postFilterCount =
+ shouldLogSyncRecovery ? localIDsToSync.length : 0;
debugPrint(
'Adding new entries for ${localIDsToSync.length} files'
' for ${deviceCollection.name}',
@@ -486,8 +487,9 @@ class RemoteSyncService {
}
}
await _db.insertMultiple(newFilesToInsert);
- final int missingFileRows =
- isInternalUser ? postFilterCount - fileFoundForLocalIDs.length : 0;
+ final int missingFileRows = shouldLogSyncRecovery
+ ? postFilterCount - fileFoundForLocalIDs.length
+ : 0;
if (missingFileRows > 0) {
final sample =
localIDsToSync.difference(fileFoundForLocalIDs).take(3);
diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
index ee62126b7b..dfc22592c8 100644
--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
@@ -106,6 +106,8 @@ class FlagService {
bool get qrFeatureEnabled => internalUser;
+ bool get syncRecoveryDiagnostics => internalUser;
+
Future<void> tryRefreshFlags() async {
try {
await _fetch();