mirror of
https://github.com/yattee/yattee.git
synced 2026-05-12 18:35:05 +00:00
Skip local-folder watches from iCloud sync
This commit is contained in:
@@ -628,9 +628,24 @@ final class CloudKitSyncEngine: @unchecked Sendable {
|
|||||||
|
|
||||||
// MARK: - WatchEntry Sync Operations
|
// MARK: - WatchEntry Sync Operations
|
||||||
|
|
||||||
|
/// Whether a watch entry is eligible for iCloud sync.
|
||||||
|
/// Local-folder media plays from a per-device path, so syncing its watch progress
|
||||||
|
/// to other devices (where the file is not reachable) is wasted noise.
|
||||||
|
private func shouldSyncWatchEntry(sourceRawValue: String, externalExtractor: String?) -> Bool {
|
||||||
|
!(sourceRawValue == "extracted" && externalExtractor == MediaFile.localFolderProvider)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func shouldSyncWatchEntry(_ watchEntry: WatchEntry) -> Bool {
|
||||||
|
shouldSyncWatchEntry(sourceRawValue: watchEntry.sourceRawValue, externalExtractor: watchEntry.externalExtractor)
|
||||||
|
}
|
||||||
|
|
||||||
/// Queue a watch entry for sync (debounced).
|
/// Queue a watch entry for sync (debounced).
|
||||||
func queueWatchEntrySave(_ watchEntry: WatchEntry) {
|
func queueWatchEntrySave(_ watchEntry: WatchEntry) {
|
||||||
guard canSyncPlaybackHistory else { return }
|
guard canSyncPlaybackHistory else { return }
|
||||||
|
guard shouldSyncWatchEntry(watchEntry) else {
|
||||||
|
LoggingService.shared.logCloudKit("Skipping local-folder watch entry: \(watchEntry.videoID)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
let record = await recordMapper.toCKRecord(watchEntry: watchEntry)
|
let record = await recordMapper.toCKRecord(watchEntry: watchEntry)
|
||||||
@@ -686,6 +701,7 @@ final class CloudKitSyncEngine: @unchecked Sendable {
|
|||||||
|
|
||||||
// Get all local watch history (limit to reasonable amount)
|
// Get all local watch history (limit to reasonable amount)
|
||||||
let watchHistory = dataManager.watchHistory(limit: 5000)
|
let watchHistory = dataManager.watchHistory(limit: 5000)
|
||||||
|
.filter { shouldSyncWatchEntry($0) }
|
||||||
|
|
||||||
guard !watchHistory.isEmpty else {
|
guard !watchHistory.isEmpty else {
|
||||||
LoggingService.shared.logCloudKit("No local watch history to upload")
|
LoggingService.shared.logCloudKit("No local watch history to upload")
|
||||||
@@ -2100,6 +2116,11 @@ extension CloudKitSyncEngine: CKSyncEngineDelegate {
|
|||||||
guard canSyncPlaybackHistory else { return .success }
|
guard canSyncPlaybackHistory else { return .success }
|
||||||
let watchEntry = try await recordMapper.toWatchEntry(from: record)
|
let watchEntry = try await recordMapper.toWatchEntry(from: record)
|
||||||
|
|
||||||
|
guard shouldSyncWatchEntry(watchEntry) else {
|
||||||
|
LoggingService.shared.logCloudKit("Ignoring incoming local-folder watch entry: \(watchEntry.videoID)")
|
||||||
|
return .success
|
||||||
|
}
|
||||||
|
|
||||||
// Check if exists locally
|
// Check if exists locally
|
||||||
if let existing = dataManager.watchEntry(for: watchEntry.videoID) {
|
if let existing = dataManager.watchEntry(for: watchEntry.videoID) {
|
||||||
// Conflict - resolve it
|
// Conflict - resolve it
|
||||||
|
|||||||
Reference in New Issue
Block a user