chore: do not process cloud ids during sync & hash (#25914)

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2026-02-05 22:53:50 +05:30 committed by GitHub
parent ba2dfa7df6
commit 2b6055e830
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 21 deletions

View file

@ -41,7 +41,7 @@ class HashService {
final Stopwatch stopwatch = Stopwatch()..start(); final Stopwatch stopwatch = Stopwatch()..start();
try { try {
// Migrate hashes from cloud ID to local ID so we don't have to re-hash them // Migrate hashes from cloud ID to local ID so we don't have to re-hash them
await _localAssetRepository.reconcileHashesFromCloudId(); // await _localAssetRepository.reconcileHashesFromCloudId();
// Sorted by backupSelection followed by isCloud // Sorted by backupSelection followed by isCloud
final localAlbums = await _localAlbumRepository.getBackupAlbums(); final localAlbums = await _localAlbumRepository.getBackupAlbums();

View file

@ -19,6 +19,7 @@ import 'package:logging/logging.dart';
class LocalSyncService { class LocalSyncService {
final DriftLocalAlbumRepository _localAlbumRepository; final DriftLocalAlbumRepository _localAlbumRepository;
// ignore: unused_field
final DriftLocalAssetRepository _localAssetRepository; final DriftLocalAssetRepository _localAssetRepository;
final NativeSyncApi _nativeSyncApi; final NativeSyncApi _nativeSyncApi;
final DriftTrashedLocalAssetRepository _trashedLocalAssetRepository; final DriftTrashedLocalAssetRepository _trashedLocalAssetRepository;
@ -53,8 +54,8 @@ class LocalSyncService {
} }
if (CurrentPlatform.isIOS) { if (CurrentPlatform.isIOS) {
final assets = await _localAssetRepository.getEmptyCloudIdAssets(); // final assets = await _localAssetRepository.getEmptyCloudIdAssets();
await _mapIosCloudIds(assets); // await _mapIosCloudIds(assets);
} }
if (full || await _nativeSyncApi.shouldFullSync()) { if (full || await _nativeSyncApi.shouldFullSync()) {
@ -306,27 +307,28 @@ class LocalSyncService {
return true; return true;
} }
// ignore: avoid-unused-parameters
Future<void> _mapIosCloudIds(List<LocalAsset> assets) async { Future<void> _mapIosCloudIds(List<LocalAsset> assets) async {
if (!CurrentPlatform.isIOS || assets.isEmpty) { // if (!CurrentPlatform.isIOS || assets.isEmpty) {
return; return;
} // }
final assetIds = assets.map((a) => a.id).toList(); // final assetIds = assets.map((a) => a.id).toList();
final cloudMapping = <String, String>{}; // final cloudMapping = <String, String>{};
final cloudIds = await _nativeSyncApi.getCloudIdForAssetIds(assetIds); // final cloudIds = await _nativeSyncApi.getCloudIdForAssetIds(assetIds);
for (int i = 0; i < cloudIds.length; i++) { // for (int i = 0; i < cloudIds.length; i++) {
final cloudIdResult = cloudIds[i]; // final cloudIdResult = cloudIds[i];
if (cloudIdResult.cloudId != null) { // if (cloudIdResult.cloudId != null) {
cloudMapping[cloudIdResult.assetId] = cloudIdResult.cloudId!; // cloudMapping[cloudIdResult.assetId] = cloudIdResult.cloudId!;
} else { // } else {
final asset = assets.firstWhereOrNull((a) => a.id == cloudIdResult.assetId); // final asset = assets.firstWhereOrNull((a) => a.id == cloudIdResult.assetId);
_log.fine( // _log.fine(
"Cannot fetch cloudId for asset with id: ${cloudIdResult.assetId}, name: ${asset?.name}, createdAt: ${asset?.createdAt}. Error: ${cloudIdResult.error ?? "unknown"}", // "Cannot fetch cloudId for asset with id: ${cloudIdResult.assetId}, name: ${asset?.name}, createdAt: ${asset?.createdAt}. Error: ${cloudIdResult.error ?? "unknown"}",
); // );
} // }
} // }
await _localAlbumRepository.updateCloudMapping(cloudMapping); // await _localAlbumRepository.updateCloudMapping(cloudMapping);
} }
bool _assetsEqual(LocalAsset a, LocalAsset b) { bool _assetsEqual(LocalAsset a, LocalAsset b) {