diff --git a/CapacitorFilesystem.podspec b/CapacitorFilesystem.podspec index 2258b30..9c5153c 100644 --- a/CapacitorFilesystem.podspec +++ b/CapacitorFilesystem.podspec @@ -13,6 +13,6 @@ Pod::Spec.new do |s| s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}' s.ios.deployment_target = '15.0' s.dependency 'Capacitor' - s.dependency 'IONFilesystemLib', spec='~> 2.0.0' + s.dependency 'IONFilesystemLib', spec='2.0.1' s.swift_version = '5.1' end diff --git a/Package.swift b/Package.swift index 75c4c33..a192134 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"), - .package(url: "https://github.com/ionic-team/ion-ios-filesystem.git", from: "2.0.0") + .package(url: "https://github.com/ionic-team/ion-ios-filesystem.git", exact: "2.0.1") ], targets: [ .target( diff --git a/ios/Sources/FilesystemPlugin/FilesystemError.swift b/ios/Sources/FilesystemPlugin/FilesystemError.swift index 030e336..808d19b 100644 --- a/ios/Sources/FilesystemPlugin/FilesystemError.swift +++ b/ios/Sources/FilesystemPlugin/FilesystemError.swift @@ -16,7 +16,7 @@ enum IONFileMethod: String { enum FilesystemError: Error { case bridgeNotInitialised case invalidInput(method: IONFileMethod) - case invalidPath(_ path: String) + case invalidPath(_ path: String, reason: Error? = nil) case fileNotFound(method: IONFileMethod, _ path: String) case directoryAlreadyExists(_ path: String) case parentDirectoryMissing @@ -46,7 +46,7 @@ private extension FilesystemError { switch self { case .bridgeNotInitialised: "Capacitor bridge isn't initialized." case .invalidInput(let method): "The '\(method.rawValue)' input parameters aren't valid." - case .invalidPath(let path): "Invalid \(!path.isEmpty ? "'" + path + "' " : "")path." + case .invalidPath(let path, let reason): "Invalid \(!path.isEmpty ? "'" + path + "' " : "")path\(reason.map { ": \($0.localizedDescription)" } ?? ".")" case .fileNotFound(let method, let path): "'\(method.rawValue)' failed because file\(!path.isEmpty ? " at '" + path + "' " : "") does not exist." case .directoryAlreadyExists(let path): "Directory\(!path.isEmpty ? " at '" + path + "' " : "") already exists, cannot be overwritten." case .parentDirectoryMissing: "Missing parent directory - possibly recursive=false was passed or parent directory creation failed." diff --git a/ios/Sources/FilesystemPlugin/FilesystemLocationResolver.swift b/ios/Sources/FilesystemPlugin/FilesystemLocationResolver.swift index c96f69e..aa749e5 100644 --- a/ios/Sources/FilesystemPlugin/FilesystemLocationResolver.swift +++ b/ios/Sources/FilesystemPlugin/FilesystemLocationResolver.swift @@ -30,10 +30,10 @@ struct FilesystemLocationResolver { } private func resolveURL(path: String, directory: IONFILESearchPath) -> Result { - return if let url = try? service.getFileURL(atPath: path, withSearchPath: directory) { - .success(url) - } else { - .failure(.invalidPath(path)) + do { + return .success(try service.getFileURL(atPath: path, withSearchPath: directory)) + } catch { + return .failure(.invalidPath(path, reason: error)) } } }