File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -106,10 +106,12 @@ final public class CoreDataWrapper {
106106 // MARK: Set configuration to context
107107 @available ( iOS 12 . 0 , macOS 10 . 13 , * )
108108 private func setConfigTo( context: NSManagedObjectContext ) {
109- context. mergePolicy = self . mergePolicy
110- context. automaticallyMergesChangesFromParent = true
111- context. shouldDeleteInaccessibleFaults = true
112- context. retainsRegisteredObjects = false
109+ if context. hasChanges == false {
110+ context. mergePolicy = self . mergePolicy
111+ context. automaticallyMergesChangesFromParent = true
112+ context. shouldDeleteInaccessibleFaults = true
113+ context. retainsRegisteredObjects = false
114+ }
113115 }
114116
115117 // MARK: Persistent store coordinator
@@ -156,6 +158,13 @@ final public class CoreDataWrapper {
156158 case . inMemory:
157159 break
158160 }
161+ do {
162+ var resourceValues : URLResourceValues = URLResourceValues . init ( )
163+ resourceValues. isExcludedFromBackup = true
164+ try storeDescription. url? . setResourceValues ( resourceValues)
165+ } catch let error {
166+ print ( " could not exlcude core data file from backup " )
167+ }
159168 storeDescription. type = storeType. getStorageType ( )
160169 storeDescription. shouldMigrateStoreAutomatically = true
161170 storeDescription. shouldInferMappingModelAutomatically = true
You can’t perform that action at this time.
0 commit comments