Skip to content

Commit

Permalink
Merge branch 'release/2.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Apr 6, 2022
2 parents f03b61d + c976b42 commit c0aa245
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 87 deletions.
4 changes: 2 additions & 2 deletions Cryptomator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2852,7 +2852,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -2914,7 +2914,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.2.1;
MARKETING_VERSION = 2.2.2;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=200 -Xfrontend -warn-long-function-bodies=200";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/cryptomator/cloud-access-swift.git",
"state": {
"branch": null,
"revision": "fa5c2e9a9db0f91981e728679fca14005d230eac",
"version": "1.2.1"
"revision": "5e089b48d0dafe15f92c199dc82bbda0aa5cfc91",
"version": "1.2.2"
}
},
{
Expand Down
5 changes: 3 additions & 2 deletions Cryptomator/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
DDLogError("Initializing CryptomatorDatabase failed with error: \(error)")
return false
}

VaultDBManager.shared.recoverMissingFileProviderDomains().catch { error in
DDLogError("Recover missing FileProvider domains failed with error: \(error)")
}
// Clean up
_ = VaultDBManager.shared.removeAllUnusedFileProviderDomains()
do {
let webDAVAccountUIDs = try CloudProviderAccountDBManager.shared.getAllAccountUIDs(for: .webDAV(type: .custom))
try WebDAVAuthenticator.removeUnusedWebDAVCredentials(existingAccountUIDs: webDAVAccountUIDs)
Expand Down
22 changes: 19 additions & 3 deletions Cryptomator/Common/CloudAuthenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2021 Skymatic GmbH. All rights reserved.
//

import CocoaLumberjackSwift
import CryptomatorCloudAccess
import CryptomatorCloudAccessCore
import CryptomatorCommonCore
Expand All @@ -16,10 +17,12 @@ import UIKit
class CloudAuthenticator {
private let accountManager: CloudProviderAccountManager
private let vaultManager: VaultManager
private let vaultAccountManager: VaultAccountManager

init(accountManager: CloudProviderAccountManager, vaultManager: VaultManager = VaultDBManager.shared) {
init(accountManager: CloudProviderAccountManager, vaultManager: VaultManager = VaultDBManager.shared, vaultAccountManager: VaultAccountManager = VaultAccountDBManager.shared) {
self.accountManager = accountManager
self.vaultManager = vaultManager
self.vaultAccountManager = vaultAccountManager
}

func authenticateDropbox(from viewController: UIViewController) -> Promise<CloudProviderAccount> {
Expand Down Expand Up @@ -102,8 +105,21 @@ class CloudAuthenticator {
case .localFileSystem:
break
}
try accountManager.removeAccount(with: account.accountUID)
_ = vaultManager.removeAllUnusedFileProviderDomains()
let correspondingVaults = try vaultAccountManager.getAllAccounts().filter { $0.delegateAccountUID == account.accountUID }
_ = Promise<Void>(on: .global()) { fulfill, _ in
for correspondingVault in correspondingVaults {
do {
try awaitPromise(self.vaultManager.removeVault(withUID: correspondingVault.vaultUID))
} catch {
DDLogError("Remove corresponding vault: \(correspondingVault.vaultName) after deauthenticated account: \(account) - failed with error: \(error)")
}
}
fulfill(())
}.then {
try self.accountManager.removeAccount(with: account.accountUID)
}.catch { error in
DDLogError("Deauthenticate account: \(account) failed with error: \(error)")
}
}
}

Expand Down
39 changes: 24 additions & 15 deletions Cryptomator/Common/EditableTableViewHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class EditableTableViewHeader: UITableViewHeaderFooterView {
return label
}()

private lazy var stack = UIStackView(arrangedSubviews: [title, editButton])

convenience init(title: String) {
self.init()
self.title.text = title.uppercased()
Expand All @@ -42,23 +44,30 @@ class EditableTableViewHeader: UITableViewHeaderFooterView {
convenience init() {
self.init(reuseIdentifier: nil)

editButton.translatesAutoresizingMaskIntoConstraints = false
title.translatesAutoresizingMaskIntoConstraints = false

contentView.addSubview(editButton)
contentView.addSubview(title)

title.setContentHuggingPriority(.defaultLow, for: .vertical)
editButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
stack.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(stack)
let topAnchor = stack.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor, constant: 20)
topAnchor.priority = .almostRequired
let bottomAnchor = stack.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor)
bottomAnchor.priority = .almostRequired
NSLayoutConstraint.activate([
title.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
title.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
title.trailingAnchor.constraint(lessThanOrEqualTo: editButton.leadingAnchor, constant: -10),
title.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor),
title.centerYAnchor.constraint(equalTo: contentView.layoutMarginsGuide.centerYAnchor),

editButton.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
editButton.trailingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor),
editButton.centerYAnchor.constraint(equalTo: contentView.layoutMarginsGuide.centerYAnchor)
topAnchor,
bottomAnchor
])
NSLayoutConstraint.activate(stack.constraints(equalTo: contentView.layoutMarginsGuide, directions: [.horizontal]))
}

func configure(with traitCollection: UITraitCollection) {
let preferredContentSize = traitCollection.preferredContentSizeCategory
if preferredContentSize.isAccessibilityCategory {
stack.axis = .vertical
stack.alignment = .leading
} else {
stack.axis = .horizontal
stack.alignment = .firstBaseline
}
}

private func changeEditButton() {
Expand Down
5 changes: 1 addition & 4 deletions Cryptomator/Common/ListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,10 @@ class ListViewController<T: TableViewCellViewModel>: BaseUITableViewController {
// MARK: - UITableViewDelegate

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
header.configure(with: tableView.traitCollection)
return header
}

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 44
}

override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .destructive, title: viewModel.removeAlert.confirmButtonText) { _, _, completion in
let alertController = UIAlertController(title: self.viewModel.removeAlert.title, message: self.viewModel.removeAlert.message, preferredStyle: .alert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public protocol VaultManager {
func manualUnlockVault(withUID vaultUID: String, kek: [UInt8]) throws -> CloudProvider
func createVaultProvider(withUID vaultUID: String, masterkey: Masterkey) throws -> CloudProvider
func removeVault(withUID vaultUID: String) throws -> Promise<Void>
func removeAllUnusedFileProviderDomains() -> Promise<Void>
func moveVault(account: VaultAccount, to targetVaultPath: CloudPath) -> Promise<Void>
func changePassphrase(oldPassphrase: String, newPassphrase: String, forVaultUID vaultUID: String) -> Promise<Void>
}
Expand Down Expand Up @@ -260,24 +259,6 @@ public class VaultDBManager: VaultManager {
}
}

public func removeAllUnusedFileProviderDomains() -> Promise<Void> {
let vaultUIDs: [String]
do {
let vaults = try vaultAccountManager.getAllAccounts()
vaultUIDs = vaults.map { $0.vaultUID }
} catch {
return Promise(error)
}
return NSFileProviderManager.getDomains().then { domains -> Promise<Void> in
let unusedDomains = domains.filter { !vaultUIDs.contains($0.identifier.rawValue) }
return self.removeDomainsFromFileProvider(unusedDomains)
}.then { _ in
DDLogInfo("Removed all unused FileProviderDomains")
}.catch { error in
DDLogError("Removing all unused FileProviderDomains failed with error: \(error)")
}
}

func removeDomainsFromFileProvider(_ domains: [NSFileProviderDomain]) -> Promise<Void> {
return Promise(on: .global()) { fulfill, _ in
for domain in domains {
Expand Down Expand Up @@ -369,6 +350,20 @@ public class VaultDBManager: VaultManager {
}
}

public func recoverMissingFileProviderDomains() -> Promise<Void> {
let vaults: [VaultAccount]
do {
vaults = try vaultAccountManager.getAllAccounts()
} catch {
return Promise(error)
}
return NSFileProviderManager.getDomains().then { domains -> Promise<Void> in
let domainIdentifiers = domains.map { $0.identifier.rawValue }
let vaultsWithMissingDomains = vaults.filter { !domainIdentifiers.contains($0.vaultUID) }
return self.recoverFileProviderDomains(for: vaultsWithMissingDomains)
}
}

// MARK: - Internal

func postProcessVaultCreation(cachedVault: CachedVault, password: String, storePasswordInKeychain: Bool) throws {
Expand Down Expand Up @@ -427,6 +422,20 @@ public class VaultDBManager: VaultManager {
let domain = NSFileProviderDomain(vaultUID: vaultUID, displayName: displayName)
return NSFileProviderManager.add(domain)
}

private func recoverFileProviderDomains(for vaults: [VaultAccount]) -> Promise<Void> {
return Promise(on: .global()) { fulfill, _ in
for vault in vaults {
do {
try awaitPromise(self.addFileProviderDomain(forVaultUID: vault.vaultUID, displayName: vault.vaultName))
DDLogInfo("Successfully recovered FileProvider domain for vault: \(vault.vaultName) - \(vault.vaultUID)")
} catch {
DDLogError("Recover FileProvider domain for vault: \(vault.vaultName) - \(vault.vaultUID) failed with error: \(error)")
}
}
fulfill(())
}
}
}

extension CloudProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,6 @@ final class VaultManagerMock: VaultManager {
return try removeVaultWithUIDClosure.map({ try $0(vaultUID) }) ?? removeVaultWithUIDReturnValue
}

// MARK: - removeAllUnusedFileProviderDomains

var removeAllUnusedFileProviderDomainsThrowableError: Error?
var removeAllUnusedFileProviderDomainsCallsCount = 0
var removeAllUnusedFileProviderDomainsCalled: Bool {
removeAllUnusedFileProviderDomainsCallsCount > 0
}

var removeAllUnusedFileProviderDomainsReturnValue: Promise<Void>!
var removeAllUnusedFileProviderDomainsClosure: (() -> Promise<Void>)?

func removeAllUnusedFileProviderDomains() -> Promise<Void> {
if let error = removeAllUnusedFileProviderDomainsThrowableError {
return Promise(error)
}
removeAllUnusedFileProviderDomainsCallsCount += 1
return removeAllUnusedFileProviderDomainsClosure.map({ $0() }) ?? removeAllUnusedFileProviderDomainsReturnValue
}

// MARK: - moveVault

var moveVaultAccountToThrowableError: Error?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
extension WebDAVAuthenticatorError: LocalizedError {
public var errorDescription: String? {
switch self {
case .unsupportedProcotol:
case .unsupportedProtocol:
return LocalizedString.getValue("webDAVAuthenticator.error.unsupportedProtocol")
case .untrustedCertificate:
return LocalizedString.getValue("webDAVAuthenticator.error.untrustedCertificate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class CacheTestCase: XCTestCase {
}

func getRandomData(sizeInBytes: Int) -> Data {
let bytes = [UInt32](repeating: 0, count: sizeInBytes).map { _ in arc4random() }
let bytes = [UInt32](repeating: 0, count: sizeInBytes).map { _ in UInt32.random(in: UInt32.min ... UInt32.max) }
let data = Data(bytes: bytes, count: sizeInBytes)
return data
}
Expand Down
4 changes: 0 additions & 4 deletions CryptomatorTests/CreateNewVaultPasswordViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ private class PasswordVaultManagerMock: VaultManager {
return Promise(MockError.notMocked)
}

func removeAllUnusedFileProviderDomains() -> Promise<Void> {
return Promise(MockError.notMocked)
}

func moveVault(account: VaultAccount, to targetVaultPath: CloudPath) -> Promise<Void> {
return Promise(MockError.notMocked)
}
Expand Down
7 changes: 2 additions & 5 deletions fastlane/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
- Fixed copying of folders that sometimes doesn't finish completely and the vault gets "stuck" (#173, #197)
- Fixed "not found" error in Google Drive due to unresolvable shortcuts (#194)
- Fixed unexpected error when the path contained certain keywords like "Shared" in OneDrive (#189)
- Fixed crash on iPad when tapping on disclosure button for signing out of a cloud storage service
- Fixed missing pCloud in settings under cloud services
- Fixed missing vaults in Files app (#176)
- Fixed missing shortcuts in Google Drive (#201)
7 changes: 2 additions & 5 deletions fastlane/metadata/de-DE/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
- Kopieren von Ordnern behoben, was manchmal nicht vollständig abgeschlossen werden konnte und der Tresor „stecken“ bleibt (#173, #197)
- Fehler „nicht gefunden“ aufgrund von nicht auflösbaren Shortcuts in Google Drive behoben (#194)
- Unerwarteten Fehler behoben, wenn der Pfad bestimmte Schlüsselwörter wie „Shared“ in OneDrive enthielt (#189)
- Absturz auf dem iPad behoben, wenn man auf den Disclosure-Button tippt, um sich von einem Cloudspeicher-Dienst abzumelden
- Fehlendes pCloud in den Einstellungen unter Cloud-Dienste behoben
- Fehlende Tresore in der App „Dateien“ behoben (#176)
- Fehlende Shortcuts in Google Drive behoben (#201)
7 changes: 2 additions & 5 deletions fastlane/metadata/en-US/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
- Fixed copying of folders that sometimes doesn't finish completely and the vault gets "stuck" (#173, #197)
- Fixed "not found" error in Google Drive due to unresolvable shortcuts (#194)
- Fixed unexpected error when the path contained certain keywords like "Shared" in OneDrive (#189)
- Fixed crash on iPad when tapping on disclosure button for signing out of a cloud storage service
- Fixed missing pCloud in settings under cloud services
- Fixed missing vaults in Files app (#176)
- Fixed missing shortcuts in Google Drive (#201)

0 comments on commit c0aa245

Please sign in to comment.