diff --git a/Packages/Weblog/Sources/WeblogPersistenceService/WeblogPersistenceService.swift b/Packages/Weblog/Sources/WeblogPersistenceService/WeblogPersistenceService.swift index a348836..d95676c 100644 --- a/Packages/Weblog/Sources/WeblogPersistenceService/WeblogPersistenceService.swift +++ b/Packages/Weblog/Sources/WeblogPersistenceService/WeblogPersistenceService.swift @@ -121,6 +121,7 @@ actor WeblogPersistenceService: WeblogPersistenceServiceProtocol { private func storeEntries( _ entries: [StorableEntry] ) throws { + try removeAllTags() try entries.forEach(storeEntry) } @@ -149,6 +150,11 @@ actor WeblogPersistenceService: WeblogPersistenceServiceProtocol { container.mainContext.insert(newTag) } + @MainActor + private func removeAllTags() throws { + try container.mainContext.delete(model: WeblogTag.self) + } + @MainActor private func removeDeletedEntries( _ entries: [StorableEntry]