|
@@ -32,18 +32,24 @@ import NCCommunication
|
|
|
return instance
|
|
|
}()
|
|
|
|
|
|
- let downloadQueue = Queuer(name: "downloadQueue", maxConcurrentOperationCount: 5, qualityOfService: .default)
|
|
|
+ var downloadQueue = Queuer(name: "downloadQueue", maxConcurrentOperationCount: 5, qualityOfService: .default)
|
|
|
let readFolderSyncQueue = Queuer(name: "readFolderSyncQueue", maxConcurrentOperationCount: 1, qualityOfService: .default)
|
|
|
let downloadThumbnailQueue = Queuer(name: "downloadThumbnailQueue", maxConcurrentOperationCount: 10, qualityOfService: .default)
|
|
|
|
|
|
+ // Download
|
|
|
@objc func download(metadata: tableMetadata, selector: String, setFavorite: Bool) {
|
|
|
downloadQueue.addOperation(NCOperationDownload.init(metadata: metadata, selector: selector, setFavorite: setFavorite))
|
|
|
}
|
|
|
+ @objc func downloadCancelAll() {
|
|
|
+ downloadQueue.cancelAll()
|
|
|
+ }
|
|
|
|
|
|
+ //
|
|
|
@objc func readFolderSync(serverUrl: String, selector: String ,account: String) {
|
|
|
readFolderSyncQueue.addOperation(NCOperationReadFolderSync.init(serverUrl: serverUrl, selector: selector, account: account))
|
|
|
}
|
|
|
|
|
|
+ //
|
|
|
@objc func downloadThumbnail(metadata: tableMetadata, activeUrl: String, view: Any, indexPath: IndexPath) {
|
|
|
if metadata.hasPreview && (!CCUtility.fileProviderStorageIconExists(metadata.ocId, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
|
|
|
downloadThumbnailQueue.addOperation(NCOperationDownloadThumbnail.init(metadata: metadata, activeUrl: activeUrl, view: view, indexPath: indexPath))
|
|
@@ -66,8 +72,12 @@ class NCOperationDownload: ConcurrentOperation {
|
|
|
}
|
|
|
|
|
|
override func start() {
|
|
|
- NCNetworking.shared.download(metadata: self.metadata, selector: self.selector, setFavorite: self.setFavorite) { (_) in
|
|
|
+ if isCancelled {
|
|
|
self.finish()
|
|
|
+ } else {
|
|
|
+ NCNetworking.shared.download(metadata: self.metadata, selector: self.selector, setFavorite: self.setFavorite) { (_) in
|
|
|
+ self.finish()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|