Skip to content

Commit cf66bfa

Browse files
committed
Fix bug in model-config
Was always overriding the path.
1 parent b2b4ed6 commit cf66bfa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/ManagedModels/Container/ModelConfiguration.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ public struct ModelConfiguration: Hashable {
1818
public var allowsSave = true
1919

2020
public var isStoredInMemoryOnly : Bool {
21-
set { path = newValue ? "/dev/null" : try! lookupDefaultPath(for: name) }
21+
set {
22+
if newValue {
23+
path = "/dev/null"
24+
}
25+
else if path == "/dev/null" {
26+
do { path = try lookupDefaultPath(for: name) }
27+
catch { fatalError("Could not lookup path for: \(name) \(error)") }
28+
}
29+
// else: preserve existing path
30+
}
2231
get { path == "/dev/null" }
2332
}
2433

@@ -63,7 +72,6 @@ public struct ModelConfiguration: Hashable {
6372
self.cloudKitDatabase = cloudKitDatabase
6473
self.schema = schema
6574
self.allowsSave = allowsSave
66-
self.isStoredInMemoryOnly = isStoredInMemoryOnly
6775
}
6876
}
6977

0 commit comments

Comments
 (0)