forked from shadowfacts/Tusker
Fix invalid names being used for persistent store
This commit is contained in:
parent
eca06cb14a
commit
0247c50650
|
@ -53,7 +53,7 @@ class MastodonCachePersistentStore: NSPersistentContainer {
|
||||||
storeDescription.type = NSInMemoryStoreType
|
storeDescription.type = NSInMemoryStoreType
|
||||||
persistentStoreDescriptions = [storeDescription]
|
persistentStoreDescriptions = [storeDescription]
|
||||||
} else {
|
} else {
|
||||||
super.init(name: "\(accountInfo!.id)_cache", managedObjectModel: MastodonCachePersistentStore.managedObjectModel)
|
super.init(name: "\(accountInfo!.persistenceKey)_cache", managedObjectModel: MastodonCachePersistentStore.managedObjectModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPersistentStores { (description, error) in
|
loadPersistentStores { (description, error) in
|
||||||
|
|
|
@ -208,6 +208,12 @@ extension LocalData {
|
||||||
self.accessToken = accessToken
|
self.accessToken = accessToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A filename-safe string for this account
|
||||||
|
var persistenceKey: String {
|
||||||
|
// slashes are not allowed in the persistent store coordinator name
|
||||||
|
id.replacingOccurrences(of: "/", with: "_")
|
||||||
|
}
|
||||||
|
|
||||||
func hash(into hasher: inout Hasher) {
|
func hash(into hasher: inout Hasher) {
|
||||||
hasher.combine(id)
|
hasher.combine(id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue