marinofaggiana 4 年 前
コミット
e8ed854071

+ 4 - 0
iOSClient/Brand/NCBrand.swift

@@ -303,6 +303,10 @@ class NCBrandColor: NSObject {
     let indexPageComments: Int                      = 1
     let indexPageSharing: Int                       = 2
     
+    // NCViewerProviderContextMenu
+    let maxAutoDownload: UInt64                     = 104857600 // 100MB
+    let maxAutoDownloadCellular: UInt64             = 10485760  // 10MB
+
     // Nextcloud unsupported
     let nextcloud_unsupported_version: Int          = 13
     

+ 3 - 0
iOSClient/Networking/NCNetworking.swift

@@ -43,6 +43,7 @@ import Queuer
     var delegate: NCNetworkingDelegate?
     
     var lastReachability: Bool = true
+    var networkReachability: NCCommunicationCommon.typeReachability?
     var downloadRequest: [String: DownloadRequest] = [:]
     var uploadRequest: [String: UploadRequest] = [:]
     var uploadMetadataInBackground: [String: tableMetadata] = [:]
@@ -121,6 +122,8 @@ import Queuer
             lastReachability = false
         }
         
+        networkReachability = typeReachability
+        
         #endif
     }
     

+ 12 - 1
iOSClient/Viewer/NCViewerProviderContextMenu.swift

@@ -86,7 +86,18 @@ class NCViewerProviderContextMenu: UIViewController  {
             
             // AUTO DOWNLOAD
             if !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-                NCOperationQueue.shared.download(metadata: metadata, selector: "", setFavorite: false)
+                
+                var maxDownload: UInt64 = 0
+                
+                if NCNetworking.shared.networkReachability == NCCommunicationCommon.typeReachability.reachableCellular {
+                    maxDownload = NCBrandGlobal.shared.maxAutoDownloadCellular
+                } else {
+                    maxDownload = NCBrandGlobal.shared.maxAutoDownload
+                }
+                
+                if metadata.size <= maxDownload {
+                    NCOperationQueue.shared.download(metadata: metadata, selector: "", setFavorite: false)
+                }
             }
             if let metadataLivePhoto = self.metadataLivePhoto {
                 if !CCUtility.fileProviderStorageExists(metadataLivePhoto.ocId, fileNameView: metadataLivePhoto.fileNameView) {