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;