mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Delete PDF files from cache when documents deleted
This commit is contained in:
parent
581c6c179b
commit
07702b61af
1 changed files with 6 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import CoreData
|
|||
import Foundation
|
||||
import Models
|
||||
import Services
|
||||
import Utils
|
||||
import Views
|
||||
|
||||
func removeLibraryItemAction(dataService: DataService, objectID: NSManagedObjectID) {
|
||||
|
|
@ -10,6 +11,11 @@ func removeLibraryItemAction(dataService: DataService, objectID: NSManagedObject
|
|||
if let item = dataService.viewContext.object(with: objectID) as? LinkedItem {
|
||||
item.state = "DELETED"
|
||||
try? dataService.viewContext.save()
|
||||
|
||||
// Delete local PDF file if it exists
|
||||
if let localPdf = item.localPDF, let localPdfURL = PDFUtils.localPdfURL(filename: localPdf) {
|
||||
try? FileManager.default.removeItem(at: localPdfURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue