Skip to content

Commit

Permalink
Fix compiler errors after fixes on swift lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gwdp committed Apr 8, 2022
1 parent abbed2d commit 4dd0be4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ios/Capacitor/Capacitor/WebViewDelegationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@ internal class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDel
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
if let pendingDownload = self.pendingDownload {
// Generate unique file name on the choosen directory
if let fileName: URL = self.getUniqueDownloadFileURL(url, suggestedFilename: pendingDownload.proposedFileName, optionalSuffix: nil) {
pendingDownload.pathSelectionCallback(fileName)
}
let fileName: URL = self.getUniqueDownloadFileURL(url, suggestedFilename: pendingDownload.proposedFileName, optionalSuffix: nil)
pendingDownload.pathSelectionCallback(fileName)
// Notify
NotificationCenter.default.post(name: .capacitorDidReceiveFileDownloadUpdate, object: [
"id": String(pendingDownload.downloadId), "status": FileDownloadNotificationStatus.started
Expand Down Expand Up @@ -395,7 +394,7 @@ internal class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDel
}

private func getUniqueDownloadFileURL(_ documentsFolderURL: URL, suggestedFilename: String, optionalSuffix: Int?) -> URL {
let suffix = ""
var suffix = ""
if let optionalSuffix = optionalSuffix { suffix = String(optionalSuffix) }
var fileComps = suggestedFilename.split(separator: ".")
var fileName = ""
Expand All @@ -408,7 +407,7 @@ internal class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDel
// Check if file with generated name exists
let documentURL = documentsFolderURL.appendingPathComponent(fileName, isDirectory: false)
if fileName == "" || FileManager.default.fileExists(atPath: documentURL.path) {
let randSuffix = 1
var randSuffix = 1
if let optionalSuffix = optionalSuffix { randSuffix = optionalSuffix + 1; }
return self.getUniqueDownloadFileURL(documentsFolderURL, suggestedFilename: suggestedFilename, optionalSuffix: randSuffix)
}
Expand Down

0 comments on commit 4dd0be4

Please sign in to comment.