Эх сурвалжийг харах

Use HTTP WebDAV instead of OCS for files_lock

- Use "LOCK" / "UNLOCK" http methods
- ignore unlock errors if file is already unlocked (412)
- use general client-side error

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 жил өмнө
parent
commit
38c8c11bb6

+ 4 - 3
iOSClient/Networking/NCNetworking.swift

@@ -1172,9 +1172,10 @@ import Queuer
     // MARK: - Lock Files
 
     @objc func lockUnlockFile(_ metadata: tableMetadata, shoulLock: Bool) {
-        NCCommunication.shared.lockUnlockFile(shouldLock: shoulLock, fileId: metadata.fileId) { errorCode, errorDescription in
-            guard errorCode == 0 else {
-                NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode, priority: .max)
+        NCCommunication.shared.lockUnlockFile(serverUrlFileName: metadata.serverUrl + "/" + metadata.fileName, shouldLock: shoulLock) { errorCode, errorDescription in
+            // 0: lock was successful; 412: lock did not change, no error, refresh
+            guard errorCode == 0 || errorCode == 412 else {
+                NCContentPresenter.shared.messageNotification(metadata.fileName, description: "_files_lock_error_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode, priority: .max)
                 return
             }
             NCNetworking.shared.readFile(serverUrlFileName: metadata.serverUrl + "/" + metadata.fileName, account: metadata.account) { account, metadata, errorCode, errorDescription in

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -267,6 +267,7 @@
 "_file_already_exists_"     = "Unable to complete the operation, a file with the same name exists";
 "_read_file_error_"         = "Could not read the file";
 "_write_file_error_"        = "Could not write the file";
+"_files_lock_error_"        = "There was an error changing the lock of this file";
 "_more_"                        = "More";
 "_notifications_"               = "Notifications";
 "_logout_"                      = "Log out";