Browse Source

Remove File Provider actions if file is locked

- Otherwise it will/would return a generic server error

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 2 years ago
parent
commit
b5a8ce5ab5
1 changed files with 5 additions and 3 deletions
  1. 5 3
      File Provider Extension/FileProviderItem.swift

+ 5 - 3
File Provider Extension/FileProviderItem.swift

@@ -60,11 +60,13 @@ class FileProviderItem: NSObject, NSFileProviderItem {
     }
 
     var capabilities: NSFileProviderItemCapabilities {
-        if metadata.directory {
+        guard !metadata.directory else {
             return [ .allowsAddingSubItems, .allowsContentEnumerating, .allowsReading, .allowsDeleting, .allowsRenaming ]
-        } else {
-            return [ .allowsWriting, .allowsReading, .allowsDeleting, .allowsRenaming, .allowsReparenting ]
         }
+        guard metadata.canUnlock(as: fileProviderData.shared.userId) else {
+            return [ .allowsReading ]
+        }
+        return [ .allowsWriting, .allowsReading, .allowsDeleting, .allowsRenaming, .allowsReparenting ]
     }
 
     var isTrashed: Bool {