Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Fixed incorrect AuthToken encoding, Query Operation not performing on…
Browse files Browse the repository at this point in the history
… correct database
  • Loading branch information
BennyKJohnson committed Nov 29, 2016
1 parent e66c92b commit fc551be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/CKContainerInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ struct CKContainerInfo {

let containerID: String

var publicCloudDBURL: URL {
let baseURL = "\(CKServerInfo.path)/database/\(CKServerInfo.version)/\(containerID)/\(environment)/public"
func publicCloudDBURL(databaseScope: CKDatabaseScope) -> URL {
let baseURL = "\(CKServerInfo.path)/database/\(CKServerInfo.version)/\(containerID)/\(environment)/\(databaseScope)"
return URL(string: baseURL)!
}

Expand Down
3 changes: 2 additions & 1 deletion Sources/CKQueryOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class CKQueryOperation: CKDatabaseOperation {

let queryOperationURLRequest = CKQueryURLRequest(query: query!, cursor: cursor?.data.bridge(), limit: resultsLimit, requestedFields: desiredKeys, zoneID: zoneID)
queryOperationURLRequest.accountInfoProvider = CloudKit.shared.defaultAccount

queryOperationURLRequest.databaseScope = database?.scope ?? .public

queryOperationURLRequest.completionBlock = { (result) in

switch result {
Expand Down
6 changes: 4 additions & 2 deletions Sources/CKURLRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CKURLRequest: NSObject {
get {
let accountInfo = accountInfoProvider ?? CloudKit.shared.defaultAccount!

let baseURL = accountInfo.containerInfo.publicCloudDBURL.appendingPathComponent("\(operationType)/\(path)")
let baseURL = accountInfo.containerInfo.publicCloudDBURL(databaseScope: databaseScope).appendingPathComponent("\(operationType)/\(path)")

var urlComponents = URLComponents(url: baseURL, resolvingAgainstBaseURL: false)!
switch accountInfo.accountType {
Expand All @@ -128,7 +128,9 @@ class CKURLRequest: NSObject {


}
//}

// Perform Encoding
urlComponents.percentEncodedQuery = urlComponents.percentEncodedQuery?.replacingOccurrences(of:"+", with: "%2B")
CloudKit.debugPrint(urlComponents.url!)
return urlComponents.url!
}
Expand Down

0 comments on commit fc551be

Please sign in to comment.