mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
optimize sync trashed assets call in full sync mode
refactor code
This commit is contained in:
parent
4d88ffe694
commit
c67a147110
2 changed files with 15 additions and 10 deletions
|
|
@ -56,10 +56,18 @@ class DriftTrashedLocalAssetRepository extends DriftDatabaseRepository {
|
|||
return rows.map((result) => result.readTable(_db.trashedLocalAssetEntity).toLocalAsset());
|
||||
}
|
||||
|
||||
Future<void> applyTrashedAssets(Iterable<TrashedAsset> trashedAssets, bool asDelta) async {
|
||||
if (asDelta){
|
||||
return _applyDelta(trashedAssets);
|
||||
} else {
|
||||
return _applySnapshot(trashedAssets);
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies resulted snapshot of trashed assets:
|
||||
/// - upserts incoming rows
|
||||
/// - deletes rows that are not present in the snapshot
|
||||
Future<void> applySnapshot(Iterable<TrashedAsset> trashedAssets) async {
|
||||
Future<void> _applySnapshot(Iterable<TrashedAsset> trashedAssets) async {
|
||||
if (trashedAssets.isEmpty) {
|
||||
await _db.delete(_db.trashedLocalAssetEntity).go();
|
||||
return;
|
||||
|
|
@ -110,7 +118,7 @@ class DriftTrashedLocalAssetRepository extends DriftDatabaseRepository {
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> applyDelta(Iterable<TrashedAsset> trashedAssets) async {
|
||||
Future<void> _applyDelta(Iterable<TrashedAsset> trashedAssets) async {
|
||||
if (trashedAssets.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue