diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Account.swift b/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Account.swift index d9b21600a..cf72c53af 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Account.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Account.swift @@ -17,9 +17,9 @@ public extension FileManager { } func accounts(for userId: UserIdentifier) -> [Mastodon.Entity.Account] { - guard let documentsDirectory else { return [] } + guard let sharedDirectory else { return [] } - let accountPath = Persistence.accounts(userId).filepath(baseURL: documentsDirectory) + let accountPath = Persistence.accounts(userId).filepath(baseURL: sharedDirectory) guard let data = try? Data(contentsOf: accountPath) else { return [] } @@ -38,14 +38,14 @@ public extension FileManager { private extension FileManager { private func storeJSON(_ encodable: Encodable, userID: UserIdentifier) { - guard let documentsDirectory else { return } + guard let sharedDirectory else { return } let jsonEncoder = JSONEncoder() jsonEncoder.dateEncodingStrategy = .iso8601 do { let data = try jsonEncoder.encode(encodable) - let accountsPath = Persistence.accounts( userID).filepath(baseURL: documentsDirectory) + let accountsPath = Persistence.accounts( userID).filepath(baseURL: sharedDirectory) try data.write(to: accountsPath) } catch { debugPrint(error.localizedDescription) diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Shared.swift b/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Shared.swift index 366ed3cb9..0afd30f2f 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Shared.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/FileManager+Shared.swift @@ -1,6 +1,7 @@ // Copyright © 2023 Mastodon gGmbH. All rights reserved. import Foundation +import MastodonCommon public extension FileManager { var documentsDirectory: URL? { @@ -10,4 +11,8 @@ public extension FileManager { var cachesDirectory: URL? { urls(for: .cachesDirectory, in: .userDomainMask).first } + + var sharedDirectory: URL? { + containerURL(forSecurityApplicationGroupIdentifier: AppName.groupID) + } }