This commit is contained in:
Neeraj Gupta
2025-07-09 09:08:21 +05:30
parent 8a7e8b8237
commit e447058573

View File

@@ -121,16 +121,19 @@ class RemoteSyncService {
// 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) {
await queueLocalAssetForUpload();
}
await _pullDiff();
await trashSyncService.syncTrash();
if (!hasSyncedBefore) {
// Handle first-time sync vs subsequent syncs
final bool isFirstSync = !_prefs.containsKey(_isFirstRemoteSyncDone);
if (isFirstSync) {
// For first sync, pull remote diff first, then queue uploads
await _pullDiff();
await trashSyncService.syncTrash();
await _prefs.setBool(_isFirstRemoteSyncDone, true);
await queueLocalAssetForUpload();
} else {
// For subsequent syncs, queue uploads before remote sync
await queueLocalAssetForUpload();
await _pullDiff();
await trashSyncService.syncTrash();
}
if (