浏览代码

FileProviderEnumeratorWorkingSet

Marino Faggiana 7 年之前
父节点
当前提交
7ce47e5996
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. 20 0
      PickerFileProvider/FileProviderEnumeratorWorkingSet.swift

+ 20 - 0
PickerFileProvider/FileProviderEnumeratorWorkingSet.swift

@@ -49,6 +49,26 @@ class FileProviderEnumeratorWorkingSet: NSObject, NSFileProviderEnumerator {
          - inform the observer about the items returned by the server (possibly multiple times)
          - inform the observer that you are finished with this page
          */
+        
+        var items: [NSFileProviderItemProtocol] = []
+        
+        let tags = NCManageDatabase.sharedInstance.getTags(predicate: NSPredicate(format: "account = %@", account))
+        
+        for tag in tags {
+            
+            if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account = %@ AND fileID = %@", account, tag.fileID))  {
+                
+                guard let serverUrl = NCManageDatabase.sharedInstance.getServerUrl(metadata.directoryID) else {
+                    continue
+                }
+                
+                let item = FileProviderItem(metadata: metadata, serverUrl: serverUrl)
+                items.append(item)
+            }
+        }
+        
+        observer.didEnumerate(items)
+        observer.finishEnumerating(upTo: nil)
     }
     
     func enumerateChanges(for observer: NSFileProviderChangeObserver, from anchor: NSFileProviderSyncAnchor) {