diff --git a/Tusker/CoreData/MastodonCachePersistentStore.swift b/Tusker/CoreData/MastodonCachePersistentStore.swift index e8846675..2fc5938c 100644 --- a/Tusker/CoreData/MastodonCachePersistentStore.swift +++ b/Tusker/CoreData/MastodonCachePersistentStore.swift @@ -53,7 +53,7 @@ class MastodonCachePersistentStore: NSPersistentContainer { storeDescription.type = NSInMemoryStoreType persistentStoreDescriptions = [storeDescription] } else { - super.init(name: "\(accountInfo!.id)_cache", managedObjectModel: MastodonCachePersistentStore.managedObjectModel) + super.init(name: "\(accountInfo!.persistenceKey)_cache", managedObjectModel: MastodonCachePersistentStore.managedObjectModel) } loadPersistentStores { (description, error) in diff --git a/Tusker/LocalData.swift b/Tusker/LocalData.swift index ba4a7e89..4da80d77 100644 --- a/Tusker/LocalData.swift +++ b/Tusker/LocalData.swift @@ -208,6 +208,12 @@ extension LocalData { 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) { hasher.combine(id) }