From 7c84f1a4a4a31bc2f02b1ce9d6f8028b3b0c1c91 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Thu, 15 Sep 2022 23:03:30 +0200 Subject: [PATCH] #335 fixed replacing entries during move/copy --- CHANGELOG.md | 1 + lib/model/source/collection_source.dart | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb939e352..9c6a6d10a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - opening viewer with directory context in some cases - photo frame widget rendering in some cases - exporting large images to BMP +- replacing entries during move/copy ## [v1.6.13] - 2022-08-29 diff --git a/lib/model/source/collection_source.dart b/lib/model/source/collection_source.dart index 7e182b0d2..20b3a5063 100644 --- a/lib/model/source/collection_source.dart +++ b/lib/model/source/collection_source.dart @@ -283,6 +283,16 @@ abstract class CollectionSource with SourceBase, AlbumMixin, LocationMixin, TagM }) async { if (movedOps.isEmpty) return; + final replacedUris = movedOps + .map((movedOp) => movedOp.newFields['path'] as String?) + .map((targetPath) { + final existingEntry = _rawEntries.firstWhereOrNull((entry) => entry.path == targetPath && !entry.trashed); + return existingEntry?.uri; + }) + .whereNotNull() + .toSet(); + await removeEntries(replacedUris, includeTrash: false); + final fromAlbums = {}; final movedEntries = {}; final copy = moveType == MoveType.copy;