File tree Expand file tree Collapse file tree
Sources/PersistentHistoryTrackingKit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,19 +29,23 @@ struct Cleaner: TransactionCleanerProtocol {
2929 func cleanTransaction( before timestamp: Date ? ) throws {
3030 guard let timestamp = timestamp else { return }
3131 try backgroundContext. performAndWait {
32- let request = getPersistentStoreRequest ( before: timestamp, for: authors)
33- try backgroundContext. execute ( request)
32+ if let request = getPersistentStoreRequest ( before: timestamp, for: authors) {
33+ try backgroundContext. execute ( request)
34+ }
3435 }
3536 }
3637
3738 // make a request for delete transactions before timestamp
38- func getPersistentStoreRequest( before timestamp: Date , for allAuthors: [ String ] ) -> NSPersistentStoreRequest {
39+ func getPersistentStoreRequest( before timestamp: Date , for allAuthors: [ String ] ) -> NSPersistentStoreRequest ? {
3940 let historyStoreRequest = NSPersistentHistoryChangeRequest . deleteHistory ( before: timestamp)
4041 if let fetchRequest = NSPersistentHistoryTransaction . fetchRequest {
4142 fetchRequest. predicate = createPredicateForAllAuthors ( allAuthors: authors)
4243 historyStoreRequest. fetchRequest = fetchRequest
44+ return historyStoreRequest
45+ }
46+ else {
47+ return nil
4348 }
44- return historyStoreRequest
4549 }
4650
4751 /// create predicate for all authors
You can’t perform that action at this time.
0 commit comments