diff --git a/RadixWallet/Clients/CacheClient/CacheClient+Interface.swift b/RadixWallet/Clients/CacheClient/CacheClient+Interface.swift index 2c27104842..b7789717eb 100644 --- a/RadixWallet/Clients/CacheClient/CacheClient+Interface.swift +++ b/RadixWallet/Clients/CacheClient/CacheClient+Interface.swift @@ -109,6 +109,8 @@ extension Address { extension CacheClient { public enum Entry: Equatable { + static let root: String = "RadixWallet" + public init(address: some AddressProtocol) { self = .onLedgerEntity(.init(address: address)) } @@ -161,7 +163,7 @@ extension CacheClient { case dateOfFirstTransaction(_ accountAddress: AccountAddress) var filesystemFilePath: String { - switch self { + let path = switch self { case let .onLedgerEntity(entity): entity.filesystemFilePath case let .networkName(url): @@ -177,6 +179,8 @@ extension CacheClient { case let .dateOfFirstTransaction(address): "\(filesystemFolderPath)/account-\(address.address)" } + + return "\(Self.root)/\(path)" } var filesystemFolderPath: String { diff --git a/RadixWallet/Clients/CacheClient/CacheClient+Live.swift b/RadixWallet/Clients/CacheClient/CacheClient+Live.swift index 86b1ff804a..8dd96b7c41 100644 --- a/RadixWallet/Clients/CacheClient/CacheClient+Live.swift +++ b/RadixWallet/Clients/CacheClient/CacheClient+Live.swift @@ -61,7 +61,7 @@ extension CacheClient: DependencyKey { @Dependency(\.diskPersistenceClient) var diskPersistenceClient do { - try diskPersistenceClient.removeAll() + try diskPersistenceClient.remove(Entry.root) loggerGlobal.debug("💾 Data successfully cleared from disk") } catch { loggerGlobal.debug("💾❌ Could not clear cached data from disk: \(error.localizedDescription)") diff --git a/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Interface.swift b/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Interface.swift index 88ecf6662c..8437610eca 100644 --- a/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Interface.swift +++ b/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Interface.swift @@ -13,7 +13,6 @@ public struct CloudBackupClient: DependencyKey, Sendable { public let lastBackup: LastBackup public let loadProfile: LoadProfile public let loadAllProfiles: LoadAllProfiles - public let backupProfile: BackupProfile public init( startAutomaticBackups: @escaping StartAutomaticBackups, @@ -23,8 +22,7 @@ public struct CloudBackupClient: DependencyKey, Sendable { checkAccountStatus: @escaping CheckAccountStatus, lastBackup: @escaping LastBackup, loadProfile: @escaping LoadProfile, - loadAllProfiles: @escaping LoadAllProfiles, - backupProfile: @escaping BackupProfile + loadAllProfiles: @escaping LoadAllProfiles ) { self.startAutomaticBackups = startAutomaticBackups self.loadDeviceID = loadDeviceID @@ -34,7 +32,6 @@ public struct CloudBackupClient: DependencyKey, Sendable { self.lastBackup = lastBackup self.loadProfile = loadProfile self.loadAllProfiles = loadAllProfiles - self.backupProfile = backupProfile } } @@ -47,7 +44,6 @@ extension CloudBackupClient { public typealias LastBackup = @Sendable (ProfileID) -> AnyAsyncSequence public typealias LoadProfile = @Sendable (ProfileID) async throws -> BackedupProfile? public typealias LoadAllProfiles = @Sendable () async throws -> [BackedupProfile] - public typealias BackupProfile = @Sendable () async throws -> CKRecord } // MARK: CloudBackupClient.BackedupProfile diff --git a/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Live.swift b/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Live.swift index 12a578bc7b..166a24acb0 100644 --- a/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Live.swift +++ b/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Live.swift @@ -152,8 +152,6 @@ extension CloudBackupClient { } let savedRecord = try await uploadProfileSnapshotToICloud(profileSnapshot, id: profile.id, existingRecord: backedUpRecord) - // Migration completed, deleting old copy - try secureStorageClient.deleteProfile(profile.id) return savedRecord } @@ -173,11 +171,6 @@ extension CloudBackupClient { }, loadAllProfiles: { try await fetchAllProfileRecords().map(extractProfile) - }, - backupProfile: { - let profile = await profileStore.profile - let existingRecord = try? await fetchProfileRecord(.init(recordName: profile.id.uuidString)) - return try await uploadProfileToICloud(profile, existingRecord: existingRecord) } ) } diff --git a/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Test.swift b/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Test.swift index ec093fbc42..3dd72516c3 100644 --- a/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Test.swift +++ b/RadixWallet/Clients/CloudBackupClient/CloudBackupClient+Test.swift @@ -22,8 +22,7 @@ extension CloudBackupClient: TestDependencyKey { checkAccountStatus: { throw NoopError() }, lastBackup: { _ in AsyncLazySequence([]).eraseToAnyAsyncSequence() }, loadProfile: { _ in throw NoopError() }, - loadAllProfiles: { throw NoopError() }, - backupProfile: { throw NoopError() } + loadAllProfiles: { throw NoopError() } ) public static let testValue = Self( @@ -34,7 +33,6 @@ extension CloudBackupClient: TestDependencyKey { checkAccountStatus: unimplemented("\(Self.self).checkAccountStatus"), lastBackup: unimplemented("\(Self.self).lastBackup"), loadProfile: unimplemented("\(Self.self).queryProfile"), - loadAllProfiles: unimplemented("\(Self.self).queryAllProfiles"), - backupProfile: unimplemented("\(Self.self).uploadProfile") + loadAllProfiles: unimplemented("\(Self.self).queryAllProfiles") ) }