Deleted stale tags before fetching new blog posts

This commit is contained in:
Otavio Cordeiro 2025-12-22 10:36:34 +01:00 committed by Otávio
parent c1aaf3af68
commit eedd369c37

View file

@ -121,6 +121,7 @@ actor WeblogPersistenceService: WeblogPersistenceServiceProtocol {
private func storeEntries( private func storeEntries(
_ entries: [StorableEntry] _ entries: [StorableEntry]
) throws { ) throws {
try removeAllTags()
try entries.forEach(storeEntry) try entries.forEach(storeEntry)
} }
@ -149,6 +150,11 @@ actor WeblogPersistenceService: WeblogPersistenceServiceProtocol {
container.mainContext.insert(newTag) container.mainContext.insert(newTag)
} }
@MainActor
private func removeAllTags() throws {
try container.mainContext.delete(model: WeblogTag.self)
}
@MainActor @MainActor
private func removeDeletedEntries( private func removeDeletedEntries(
_ entries: [StorableEntry] _ entries: [StorableEntry]