mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	fix(mobile): update local deleted assets in sync (#5099)
This commit is contained in:
		
							parent
							
								
									47a4984a56
								
							
						
					
					
						commit
						63a745c7ad
					
				@ -785,15 +785,20 @@ class SyncService {
 | 
				
			|||||||
  bool? remote,
 | 
					  bool? remote,
 | 
				
			||||||
  int Function(Asset, Asset) compare = Asset.compareByChecksum,
 | 
					  int Function(Asset, Asset) compare = Asset.compareByChecksum,
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
 | 
					  // fast paths for trivial cases: reduces memory usage during initial sync etc.
 | 
				
			||||||
 | 
					  if (assets.isEmpty && inDb.isEmpty) {
 | 
				
			||||||
 | 
					    return const ([], [], []);
 | 
				
			||||||
 | 
					  } else if (assets.isEmpty && remote == null) {
 | 
				
			||||||
 | 
					    // remove all from database
 | 
				
			||||||
 | 
					    return (const [], const [], inDb);
 | 
				
			||||||
 | 
					  } else if (inDb.isEmpty) {
 | 
				
			||||||
 | 
					    // add all assets
 | 
				
			||||||
 | 
					    return (assets, const [], const []);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  final List<Asset> toAdd = [];
 | 
					  final List<Asset> toAdd = [];
 | 
				
			||||||
  final List<Asset> toUpdate = [];
 | 
					  final List<Asset> toUpdate = [];
 | 
				
			||||||
  final List<Asset> toRemove = [];
 | 
					  final List<Asset> toRemove = [];
 | 
				
			||||||
  if (assets.isEmpty || inDb.isEmpty) {
 | 
					 | 
				
			||||||
    // fast path for trivial cases: halfes memory usage during initial sync
 | 
					 | 
				
			||||||
    return assets.isEmpty
 | 
					 | 
				
			||||||
        ? (toAdd, toUpdate, inDb) // remove all from DB
 | 
					 | 
				
			||||||
        : (assets, toUpdate, toRemove); // add all assets
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  diffSortedListsSync(
 | 
					  diffSortedListsSync(
 | 
				
			||||||
    inDb,
 | 
					    inDb,
 | 
				
			||||||
    assets,
 | 
					    assets,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user