marinofaggiana 4 years ago
parent
commit
d88d9fc7b4

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -2822,8 +2822,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
-				kind = exactVersion;
-				version = 0.94.0;
+				kind = revision;
+				revision = 878c84b6a67ba09e52410e0574386ddc545270c0;
 			};
 		};
 		F7C4D88B2534887E00C142DA /* XCRemoteSwiftPackageReference "Parchment" */ = {

+ 2 - 2
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -24,8 +24,8 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "9eae0eaafdaa2bcb208c35da35fc6c07cfc32bbc",
-          "version": "0.94.0"
+          "revision": "878c84b6a67ba09e52410e0574386ddc545270c0",
+          "version": null
         }
       },
       {

+ 0 - 1
iOSClient/Data/NCDatabase.swift

@@ -307,7 +307,6 @@ class tableMetadata: Object {
     @objc dynamic var account = ""
     @objc dynamic var assetLocalIdentifier = ""
     @objc dynamic var chunk: Bool = false
-    @objc dynamic var chunkFolder = ""
     @objc dynamic var commentsUnread: Bool = false
     @objc dynamic var contentType = ""
     @objc dynamic var creationDate = NSDate()

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -59,7 +59,7 @@ class NCGlobal: NSObject {
 
     // Database Realm
     let databaseDefault                             = "nextcloud.realm"
-    let databaseSchemaVersion: UInt64               = 167
+    let databaseSchemaVersion: UInt64               = 168
     
     // Intro selector
     @objc let introLogin: Int                       = 0

+ 3 - 48
iOSClient/Networking/NCNetworking.swift

@@ -456,8 +456,8 @@ import Queuer
         let directoryProviderStorageOcId = CCUtility.getDirectoryProviderStorageOcId(ocId)!
         let uploadFolder = metadata.urlBase + "/" + NCUtilityFileSystem.shared.getDAV() + "/uploads/" + userId + "/" + folderChunk
         var uploadErrorCode: Int = 0
-        
-        if let filesNames = self.fileChunks(path: directoryProviderStorageOcId, fileName: metadata.fileName, pathChunks: directoryProviderStorageOcId, size: 10) {
+                
+        if let filesNames = NCCommunicationCommon.shared.fileChunks(path: directoryProviderStorageOcId, fileName: metadata.fileName, pathChunks: directoryProviderStorageOcId, sizeInMB: 10) {
         
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl":serverUrl])
             
@@ -477,7 +477,7 @@ import Queuer
                             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
                             let semaphore = Semaphore()
 
-                            NCCommunication.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: nil, dateModificationFile: nil, requestHandler: { (request) in
+                            NCCommunication.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (request) in
                                     //
                             }, taskHandler: { (task) in
                                     //
@@ -1422,51 +1422,6 @@ import Queuer
     
     //MARK: - TEST API
         
-    /*
-     
-     XXXXXXXXXXXXXXX-YYYYYYYYYYYYYYY
-
-     Where XXXXXXXXXXXXXXX is the start byte of the chunk (with leading zeros) and YYYYYYYYYYYYYYY is the end byte of the chunk with leading zeros.
-
-     curl -X PUT -u roeland:pass https://server/remote.php/dav/uploads/roeland/myapp-e1663913-4423-4efe-a9cd-26e7beeca3c0/000000000000000-000000010485759 -d @chunk1 curl -X PUT -u roeland:pass https://server/remote.php/dav/uploads/roeland/myapp-e1663913-4423-4efe-a9cd-26e7beeca3c0/000000010485760-000000015728640 -d @chunk2
-
-     This will upload 2 chunks of a file. The first chunk is 10MB in size and the second chunk is 5MB in size.
-     
-     */
-    
-    func fileChunks(path: String, fileName: String, pathChunks: String, size: Int) -> [String]? {
-           
-        var filesNameOut: [String] = []
-        
-        do {
-            let data = try Data(contentsOf: URL(fileURLWithPath: path + "/" + fileName))
-            let dataLen = data.count
-            let chunkSize = ((1024 * 1000) * size) // MB
-            let fullChunks = Int(dataLen / chunkSize)
-            let totalChunks = fullChunks + (dataLen % 1024 != 0 ? 1 : 0)
-                
-            for chunkCounter in 0..<totalChunks {
-                
-                let chunkBase = chunkCounter * chunkSize
-                var diff = chunkSize
-                if chunkCounter == totalChunks - 1 {
-                    diff = dataLen - chunkBase
-                }
-                    
-                let range:Range<Data.Index> = chunkBase..<(chunkBase + diff)
-                let chunk = data.subdata(in: range)
-                                
-                let fileNameOut = fileName + "." + String(format: "%010d", chunkCounter)
-                try chunk.write(to: URL(fileURLWithPath: pathChunks + "/" + fileNameOut))
-                filesNameOut.append(fileNameOut)
-            }
-        } catch {
-            return nil
-        }
-        
-        return filesNameOut
-    }
-    
     /*
     @objc public func getAppPassword(serverUrl: String, username: String, password: String, customUserAgent: String? = nil, completionHandler: @escaping (_ token: String?, _ errorCode: Int, _ errorDescription: String) -> Void) {