diff --git a/.travis.yml b/.travis.yml index dcbcd30..8b6b3a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ before_deploy: deploy: provider: releases - api_key: $GITHUBTOKEN + api_key: "$GITHUBTOKEN" file: $FRAMEWORK_NAME.zip skip_cleanup: true on: diff --git a/FileProvider.podspec b/FileProvider.podspec index 5df38cd..e8158af 100644 --- a/FileProvider.podspec +++ b/FileProvider.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "FileProvider" - s.version = "0.12.5" + s.version = "0.12.6" s.summary = "FileManager replacement for Local and Remote (WebDAV/Dropbox/OneDrive/SMB2) files on iOS and macOS." # This description is used to generate tags and improve search results. diff --git a/FileProvider.xcodeproj/project.pbxproj b/FileProvider.xcodeproj/project.pbxproj index f1d1602..39c05c7 100644 --- a/FileProvider.xcodeproj/project.pbxproj +++ b/FileProvider.xcodeproj/project.pbxproj @@ -597,7 +597,7 @@ 799396601D48B7BF00086753 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - BUNDLE_VERSION_STRING = 0.12.5; + BUNDLE_VERSION_STRING = 0.12.6; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -627,7 +627,7 @@ 799396611D48B7BF00086753 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - BUNDLE_VERSION_STRING = 0.12.5; + BUNDLE_VERSION_STRING = 0.12.6; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; diff --git a/Sources/CloudFileProvider.swift b/Sources/CloudFileProvider.swift index c9204a4..6631fcf 100644 --- a/Sources/CloudFileProvider.swift +++ b/Sources/CloudFileProvider.swift @@ -28,6 +28,7 @@ open class CloudFileProvider: LocalFileProvider { /// Scope of container, indicates user can manipulate data/files or not. open fileprivate(set) var scope: UbiquitousScope + static open var asserting: Bool = true /** Initializes the provider for the iCloud container associated with the specified identifier and establishes access to that container. @@ -40,8 +41,8 @@ open class CloudFileProvider: LocalFileProvider { - Parameter scope: Use `.documents` (default) to put documents that the user is allowed to access inside a Documents subdirectory. Otherwise use `.data` to store user-related data files that your app needs to share but that are not files you want the user to manipulate directly. */ public init? (containerId: String?, scope: UbiquitousScope = .documents) { - assert(!Thread.isMainThread, "LocalFileProvider.init(containerId:) is not recommended to be executed on Main Thread.") - guard FileManager.default.ubiquityIdentityToken == nil else { + assert(!CloudFileProvider.asserting || !Thread.isMainThread, "LocalFileProvider.init(containerId:) is not recommended to be executed on Main Thread.") + guard FileManager.default.ubiquityIdentityToken != nil else { return nil } guard let ubiquityURL = FileManager.default.url(forUbiquityContainerIdentifier: containerId) else { diff --git a/Sources/LocalFileProvider.swift b/Sources/LocalFileProvider.swift index 0252844..152ec50 100644 --- a/Sources/LocalFileProvider.swift +++ b/Sources/LocalFileProvider.swift @@ -73,7 +73,7 @@ open class LocalFileProvider: FileProvider, FileProviderMonitor, FileProvideUndo case .cachesDirectory: finalBaseURL = baseURL.appendingPathComponent("Library/Caches") case .applicationSupportDirectory: - finalBaseURL = baseURL.appendingPathComponent("Library/Application%20support") + finalBaseURL = baseURL.appendingPathComponent("Library/Application support") default: break } diff --git a/Sources/LocalHelper.swift b/Sources/LocalHelper.swift index 05ada33..e17d539 100644 --- a/Sources/LocalHelper.swift +++ b/Sources/LocalHelper.swift @@ -15,7 +15,7 @@ public final class LocalFileObject: FileObject { public convenience init? (fileWithPath path: String, relativeTo relativeURL: URL?) { var fileURL: URL? - var rpath = path.replacingOccurrences(of: relativeURL?.absoluteString ?? "", with: "", options: .anchored) + var rpath = path.replacingOccurrences(of: relativeURL?.path ?? "", with: "", options: .anchored) if path.hasPrefix("/") { rpath.remove(at: rpath.startIndex) } diff --git a/Sources/OneDriveFileProvide.swift b/Sources/OneDriveFileProvide.swift index 8b84a71..2921030 100644 --- a/Sources/OneDriveFileProvide.swift +++ b/Sources/OneDriveFileProvide.swift @@ -67,7 +67,8 @@ open class OneDriveFileProvider: FileProviderBasicRemote { - cache: A URLCache to cache downloaded files and contents. If set to nil, URLCache.shared object will be used. */ public init(credential: URLCredential?, serverURL: URL? = nil, drive: String = "root", cache: URLCache? = nil) { - self.baseURL = (serverURL ?? URL(string: "https://api.onedrive.com/")!).appendingPathComponent("") + let baseURL = serverURL ?? URL(string: "https://api.onedrive.com/")! + self.baseURL = baseURL.path.hasSuffix("/") ? baseURL : baseURL.appendingPathComponent("") self.drive = drive self.isPathRelative = true self.currentPath = "" diff --git a/Sources/WebDAVFileProvider.swift b/Sources/WebDAVFileProvider.swift index 6bb2c46..2c74488 100644 --- a/Sources/WebDAVFileProvider.swift +++ b/Sources/WebDAVFileProvider.swift @@ -57,7 +57,7 @@ open class WebDAVFileProvider: FileProviderBasicRemote { if !["http", "https"].contains(baseURL.uw_scheme.lowercased()) { return nil } - self.baseURL = baseURL.appendingPathComponent("") + self.baseURL = baseURL.path.hasSuffix("/") ? baseURL : baseURL.appendingPathComponent("") self.isPathRelative = true self.currentPath = "" self.useCache = false