Skip to content

armgit / ente

Public Imported from GitHub
0

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

Run check in small chunk

Neeraj Gupta21b9905a6f54
diff --git a/lib/services/local_file_update_service.dart b/lib/services/local_file_update_service.dart
index 22782589e0..5d05193f79 100644
--- a/lib/services/local_file_update_service.dart
+++ b/lib/services/local_file_update_service.dart
@@ -7,6 +7,7 @@ import "package:photos/core/configuration.dart";
import 'package:photos/core/errors.dart';
import 'package:photos/db/file_updation_db.dart';
import 'package:photos/db/files_db.dart';
+import "package:photos/extensions/list.dart";
import "package:photos/extensions/stop_watch.dart";
import 'package:photos/models/file/file.dart';
import 'package:photos/models/file/file_type.dart';
@@ -214,26 +215,30 @@ class LocalFileUpdateService {
return;
}
await _importLivePhotoReUploadCandidates();
- final sTime = DateTime.now().microsecondsSinceEpoch;
+
// singleRunLimit indicates number of files to check during single
// invocation of this method. The limit act as a crude way to limit the
// resource consumed by the method
- const int singleRunLimit = 75;
+ const int singleRunLimit = 500;
final localIDsToProcess =
await _fileUpdationDB.getLocalIDsForPotentialReUpload(
singleRunLimit,
FileUpdationDB.livePhotoCheck,
);
if (localIDsToProcess.isNotEmpty) {
- await _checkLivePhotoWithLowOrUnknownSize(
- localIDsToProcess,
- );
- final eTime = DateTime.now().microsecondsSinceEpoch;
- final d = Duration(microseconds: eTime - sTime);
- _logger.info(
- 'Performed hashCheck for ${localIDsToProcess.length} livePhoto files '
- 'completed in ${d.inSeconds.toString()} secs',
- );
+ final chunks = localIDsToProcess.chunks(10);
+ for (final chunk in chunks) {
+ final sTime = DateTime.now().microsecondsSinceEpoch;
+ await _checkLivePhotoWithLowOrUnknownSize(
+ chunk,
+ );
+ final eTime = DateTime.now().microsecondsSinceEpoch;
+ final d = Duration(microseconds: eTime - sTime);
+ _logger.info(
+ 'Performed hashCheck for ${chunk.length} livePhoto files '
+ 'completed in ${d.inSeconds.toString()} secs',
+ );
+ }
} else {
await _prefs.setBool(_iosLivePhotoSizeMigrationDone, true);
}