Marino Faggiana 6 年之前
父節點
當前提交
4ec2619258
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      PickerFileProvider/FileProvider.swift

+ 11 - 2
PickerFileProvider/FileProvider.swift

@@ -960,6 +960,9 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
             
             
             if (errorCode == 0) {
             if (errorCode == 0) {
                 
                 
+                let sourcePath = fileProviderStorageURL!.path + "/" + fileName
+                let destinationPath = fileProviderStorageURL!.path + "/" + fileID + "/" + fileName
+                
                 NCManageDatabase.sharedInstance.setLocalFile(fileID: fileID, date: nil, exifDate: nil, exifLatitude: nil, exifLongitude: nil, fileName: nil, etag: metadata.etag, etagFPE: metadata.etag)
                 NCManageDatabase.sharedInstance.setLocalFile(fileID: fileID, date: nil, exifDate: nil, exifLatitude: nil, exifLongitude: nil, fileName: nil, etag: metadata.etag, etagFPE: metadata.etag)
                 
                 
                 do {
                 do {
@@ -967,12 +970,18 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
                 } catch { }
                 } catch { }
                 
                 
                 do {
                 do {
-                    try FileManager.default.removeItem(atPath: fileProviderStorageURL!.path + "/" + fileID + "/" + fileName)
+                    try FileManager.default.removeItem(atPath: destinationPath)
                 } catch { }
                 } catch { }
                 do {
                 do {
-                    try FileManager.default.copyItem(atPath: fileProviderStorageURL!.path + "/" + fileName, toPath: fileProviderStorageURL!.path + "/" + fileID + "/" + fileName)
+                    try FileManager.default.copyItem(atPath: sourcePath, toPath: destinationPath)
+                    
                     let item = FileProviderItem(metadata: metadata, serverUrl: serverUrl)
                     let item = FileProviderItem(metadata: metadata, serverUrl: serverUrl)
                     self.refreshEnumerator(identifier: item.itemIdentifier, serverUrl: serverUrl)
                     self.refreshEnumerator(identifier: item.itemIdentifier, serverUrl: serverUrl)
+                    
+                    do {
+                        try FileManager.default.removeItem(atPath: sourcePath)
+                    } catch { }
+                    
                 } catch { }
                 } catch { }
             }
             }
         }
         }