marinofaggiana 3 жил өмнө
parent
commit
40e428954b

+ 4 - 1
iOSClient/Main/NCFunctionCenter.swift

@@ -313,8 +313,11 @@ import NCCommunication
     func saveBackground(metadata: tableMetadata) {
         
         let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
-
+        let destination = CCUtility.getDirectoryGroup().appendingPathComponent(NCGlobal.shared.appBackground).path + "/" + metadata.fileNameView
         
+        if NCUtilityFileSystem.shared.copyFile(atPath: fileNamePath, toPath: destination) {
+            
+        }
     }
     
     // MARK: - Copy & Paste

+ 21 - 0
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -130,6 +130,27 @@ class NCUtilityFileSystem: NSObject {
         }
     }
     
+    @objc func copyFile(atPath: String, toPath: String) -> Bool {
+
+        if atPath == toPath { return true }
+    
+        do {
+            try FileManager.default.removeItem(atPath: toPath)
+        }
+        catch {
+            print(error)
+        }
+                
+        do {
+            try FileManager.default.copyItem(atPath: atPath, toPath: toPath)
+            return true
+        }
+        catch {
+            print(error)
+            return false
+        }
+    }
+    
     @objc func moveFileInBackground(atPath: String, toPath: String) {
         
         if atPath == toPath { return }