Implement incremental sync and offline recovery

This commit is contained in:
diyaa
2026-06-15 22:31:23 +02:00
parent fa7727d572
commit 295c6c1d9b
25 changed files with 2293 additions and 494 deletions
@@ -476,13 +476,15 @@ final class iPhoneLibraryViewModel {
}
)
let store = Self.makeRemoteLibraryStore()
let syncCursorStore = Self.makeRemoteLibrarySyncCursorStore()
let downloadStateStore = Self.makeRemoteTrackDownloadStateStore()
let audioFileStore = Self.makeOfflineAudioFileStore()
let artworkStore = Self.makeArtworkStore()
let favoriteTrackStore = Self.makeFavoriteTrackStore()
let repository = DefaultRemoteLibraryRepository(
apiClient: apiClient,
store: store
store: store,
syncCursorStore: syncCursorStore
)
let syncService = RemoteLibrarySyncService(
repository: repository,
@@ -726,6 +728,14 @@ final class iPhoneLibraryViewModel {
return InMemoryRemoteTrackDownloadStateStore()
}
private static func makeRemoteLibrarySyncCursorStore() -> any RemoteLibrarySyncCursorStore {
if let store = try? FileRemoteLibrarySyncCursorStore() {
return store
}
return InMemoryRemoteLibrarySyncCursorStore()
}
private static func makeOfflineAudioFileStore() -> any OfflineAudioFileStore {
if let store = try? FileOfflineAudioFileStore() {
return store