Parcourir la source

fix progress view

marinofaggiana il y a 4 ans
Parent
commit
04d9cfc2f6
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      iOSClient/Networking/NCNetworkingChunkedUpload.swift

+ 6 - 7
iOSClient/Networking/NCNetworkingChunkedUpload.swift

@@ -38,7 +38,6 @@ extension NCNetworking {
         var uploadErrorCode: Int = 0
         var uploadErrorDescription: String = ""
         var filesNames = NCManageDatabase.shared.getChunks(account: metadata.account, ocId: metadata.ocId)
-        var progress: Float = 0
         
         if filesNames.count == 0 {
                         
@@ -87,14 +86,14 @@ extension NCNetworking {
                             self.uploadRequest[fileNameLocalPath] = request
                             
                             let chunksremains = NCManageDatabase.shared.getChunks(account: metadata.account, ocId: metadata.ocId).count
-                            let totalBytes = counter * chunkSize
+                            let totalBytes = (counter + 1) * chunkSize
                             let totalBytesExpected: Int64 = metadata.size
-                            
-                            let tempProgress: Float = Float(totalBytes) / Float(totalBytesExpected)
-                            if tempProgress >= progress {
-                                progress = tempProgress
-                            } else {
+                            var progress: Float = 0
+
+                            if chunksremains == 1 {
                                 progress = 1
+                            } else {
+                                progress = Float(totalBytes) / Float(totalBytesExpected)
                             }
                             
                             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterProgressTask, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":metadata.serverUrl, "status":NSNumber(value: NCGlobal.shared.metadataStatusInUpload), "progress":NSNumber(value: progress), "totalBytes":NSNumber(value: totalBytes), "totalBytesExpected":NSNumber(value: totalBytesExpected)])