Skip to content

Commit

Permalink
Merge branch 'release/1.7.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Mar 10, 2023
2 parents 55eb376 + 491a19e commit c9eaa84
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
continue-on-error: true
- name: Run integration tests
if: startsWith(github.ref, 'refs/tags/')
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -scheme 'CryptomatorCloudAccessIntegrationTests' -destination "name=$DEVICE" -derivedDataPath $DERIVED_DATA_PATH test | xcpretty
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -scheme 'CryptomatorCloudAccessIntegrationTests' -destination "name=$DEVICE" -derivedDataPath $DERIVED_DATA_PATH -retry-tests-on-failure test | xcpretty
env:
DROPBOX_ACCESS_TOKEN: ${{ secrets.DROPBOX_ACCESS_TOKEN }}
GOOGLE_DRIVE_CLIENT_ID: ${{ secrets.GOOGLE_DRIVE_CLIENT_ID }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ public class GoogleDriveCloudProvider: CloudProvider {
let name = endCloudPath.pathComponents[i]
currentPath = currentPath.appendingPathComponent(name)
parentItem = try awaitPromise(self.getGoogleDriveItem(name: name, parentItem: parentItem))
try self.identifierCache.addOrUpdate(parentItem)
}
fulfill(parentItem)
}
Expand All @@ -393,11 +394,8 @@ public class GoogleDriveCloudProvider: CloudProvider {
CloudAccessDDLogDebug("GoogleDriveCloudProvider: getGoogleDriveItem(name: \(name), parentItem: \(parentItem.identifier)) received result: \((result as? GTLRObject)?.jsonString() ?? result)")
if let fileList = result as? GTLRDrive_FileList {
for file in fileList.files ?? [GTLRDrive_File]() where file.name == name {
let item = try GoogleDriveItem(cloudPath: parentItem.cloudPath.appendingPathComponent(name), file: file)
try self.identifierCache.addOrUpdate(item)
return item
return try GoogleDriveItem(cloudPath: parentItem.cloudPath.appendingPathComponent(name), file: file)
}
try self.identifierCache.invalidate(parentItem)
throw CloudProviderError.itemNotFound
} else {
throw GoogleDriveError.unexpectedResultType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,33 @@ public class LocalFileSystemProvider: CloudProvider {
}

private func fillCacheAfterCheck(for cloudPath: CloudPath, url: URL, directoryEnumerator: FileManager.DirectoryEnumerator, promise: Promise<Void>) {
var cachedItemsCount: Int64 = 0
for case let childURL as URL in directoryEnumerator {
autoreleasepool {
guard !childURL.isHidden || self.fileManager.isUbiquitousItem(at: childURL) else {
return
}
let iCloudCompatibleChildURL = url.appendingPathComponent(self.getItemName(forItemAt: childURL))
guard iCloudCompatibleChildURL.lastPathComponent.prefix(1) != "." else {
return
}
do {
let childItemMetadata = try awaitPromise(self.getItemMetadata(forItemAt: iCloudCompatibleChildURL, parentCloudPath: cloudPath))
cachedItemsCount += 1
try self.cache.save(childItemMetadata, for: cloudPath, index: cachedItemsCount)
} catch CloudProviderError.itemNotFound {
// Ignore item that can't be found anyway, this should not prevent fetching item list
return
} catch {
CloudAccessDDLogDebug("LocalFileSystemProvider: fillCache(for: \(cloudPath.path)) failed with error: \(error)")
promise.reject(error)
return
do {
var cachedItemsCount: Int64 = 0
for case let childURL as URL in directoryEnumerator {
try autoreleasepool {
guard !childURL.isHidden || self.fileManager.isUbiquitousItem(at: childURL) else {
return
}
let iCloudCompatibleChildURL = url.appendingPathComponent(self.getItemName(forItemAt: childURL))
guard iCloudCompatibleChildURL.lastPathComponent.prefix(1) != "." else {
return
}
do {
let childItemMetadata = try awaitPromise(self.getItemMetadata(forItemAt: iCloudCompatibleChildURL, parentCloudPath: cloudPath))
cachedItemsCount += 1
try self.cache.save(childItemMetadata, for: cloudPath, index: cachedItemsCount)
} catch CloudProviderError.itemNotFound {
// Ignore item that can't be found anyway, this should not prevent fetching item list
return
}
}
}
CloudAccessDDLogDebug("LocalFileSystemProvider: fillCache(for: \(cloudPath.path)) finished")
promise.fulfill(())
} catch {
CloudAccessDDLogDebug("LocalFileSystemProvider: fillCache(for: \(cloudPath.path)) failed with error: \(error)")
promise.reject(error)
}
CloudAccessDDLogDebug("LocalFileSystemProvider: fillCache(for: \(cloudPath.path)) finished")
promise.fulfill(())
}

private func getCachedElements(for cloudPath: CloudPath, pageToken: String?) -> Promise<CloudItemList> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ public class OneDriveCloudProvider: CloudProvider {
let itemName = endCloudPath.pathComponents[i]
currentPath = currentPath.appendingPathComponent(itemName)
parentItem = try awaitPromise(self.getOneDriveItem(for: itemName, withParentItem: parentItem))
try self.identifierCache.addOrUpdate(parentItem)
}
fulfill(parentItem)
}
Expand All @@ -557,14 +558,7 @@ public class OneDriveCloudProvider: CloudProvider {
let request = NSMutableURLRequest(url: url)
return executeMSURLSessionDataTaskWithErrorMapping(with: request).then { data -> OneDriveItem in
let driveItem = try MSGraphDriveItem(data: data)
let item = OneDriveItem(cloudPath: parentItem.cloudPath.appendingPathComponent(name), driveItem: driveItem)
try self.identifierCache.addOrUpdate(item)
return item
}.recover { error -> OneDriveItem in
if case CloudProviderError.itemNotFound = error {
try self.identifierCache.invalidate(parentItem)
}
throw error
return OneDriveItem(cloudPath: parentItem.cloudPath.appendingPathComponent(name), driveItem: driveItem)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public class PCloudCloudProvider: CloudProvider {
let itemName = endCloudPath.pathComponents[i]
currentPath = currentPath.appendingPathComponent(itemName)
parentItem = try awaitPromise(self.getPCloudItem(for: itemName, withParentItem: parentItem))
try self.identifierCache.addOrUpdate(parentItem)
}
fulfill(parentItem)
}
Expand All @@ -439,16 +440,13 @@ public class PCloudCloudProvider: CloudProvider {
guard let content = metadata.contents.first(where: { $0.fileMetadata?.name == name || $0.folderMetadata?.name == name }) else {
throw CloudProviderError.itemNotFound
}
let item = try PCloudItem(cloudPath: parentItem.cloudPath.appendingPathComponent(name), content: content)
try self.identifierCache.addOrUpdate(item)
return item
return try PCloudItem(cloudPath: parentItem.cloudPath.appendingPathComponent(name), content: content)
}.recover { error -> PCloudItem in
CloudAccessDDLogDebug("PCloudCloudProvider: getPCloudItem(for: \(name), withParentItem: \(parentItem.identifier)) failed with error: \(error)")
guard let error = error as? CallError<PCloudAPI.ListFolder.Error> else {
throw error
}
if case CallError.methodError(.folderDoesNotExist) = error {
try self.identifierCache.invalidate(parentItem)
throw CloudProviderError.itemNotFound
} else {
throw error
Expand Down

0 comments on commit c9eaa84

Please sign in to comment.