Add method to report a change in sync state if applicable in FileProviderExt

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-07-16 19:19:58 +08:00
parent 5237822221
commit 885d9f3566
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -132,4 +132,22 @@ extension FileProviderExtension: NSFileProviderServicing, ChangeNotificationInte
)
ncAccount = nil
}
func updatedSyncStateReporting(oldActions: Set<UUID>) {
guard oldActions.isEmpty != syncActions.isEmpty else { return }
let command = "FILE_PROVIDER_DOMAIN_SYNC_STATE_CHANGE"
var argument: String?
if oldActions.isEmpty, !syncActions.isEmpty {
argument = "SYNC_STARTED"
} else if !oldActions.isEmpty, syncActions.isEmpty {
argument = errorActions.isEmpty ? "SYNC_FINISHED" : "SYNC_FAILED"
errorActions = []
}
guard let argument else { return }
Logger.fileProviderExtension.debug("Reporting sync \(argument)")
let message = command + ":" + argument + "\n"
socketClient?.sendMessage(message)
}
}