}
func updatedSyncStateReporting(oldActions: Set<UUID>) {
- guard oldActions.isEmpty != syncActions.isEmpty else { return }
+ actionsLock.lock()
+
+ guard oldActions.isEmpty != syncActions.isEmpty else {
+ actionsLock.unlock()
+ return
+ }
let command = "FILE_PROVIDER_DOMAIN_SYNC_STATE_CHANGE"
var argument: String?
argument = errorActions.isEmpty ? "SYNC_FINISHED" : "SYNC_FAILED"
errorActions = []
}
+
+ actionsLock.unlock()
guard let argument else { return }
Logger.fileProviderExtension.debug("Reporting sync \(argument)")
var syncActions = Set<UUID>()
var errorActions = Set<UUID>()
+ var actionsLock = NSLock()
// Whether or not we are going to recursively scan new folders when they are discovered.
// Apple's recommendation is that we should always scan the file hierarchy fully.
}
func insertSyncAction(_ actionId: UUID) {
+ actionsLock.lock()
let oldActions = syncActions
syncActions.insert(actionId)
+ actionsLock.unlock()
updatedSyncStateReporting(oldActions: oldActions)
}
func insertErrorAction(_ actionId: UUID) {
+ actionsLock.lock()
let oldActions = syncActions
syncActions.remove(actionId)
errorActions.insert(actionId)
+ actionsLock.unlock()
updatedSyncStateReporting(oldActions: oldActions)
}
func removeSyncAction(_ actionId: UUID) {
+ actionsLock.lock()
let oldActions = syncActions
syncActions.remove(actionId)
errorActions.remove(actionId)
+ actionsLock.unlock()
updatedSyncStateReporting(oldActions: oldActions)
}