|
@@ -88,8 +88,6 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
|
|
|
super.init()
|
|
|
|
|
|
- setupActiveAccount()
|
|
|
-
|
|
|
verifyUploadQueueInLock()
|
|
|
|
|
|
if #available(iOSApplicationExtension 11.0, *) {
|
|
@@ -128,6 +126,11 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
throw NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError, userInfo:[:])
|
|
|
}
|
|
|
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo:[:])
|
|
|
+ }
|
|
|
+
|
|
|
var maybeEnumerator: NSFileProviderEnumerator? = nil
|
|
|
|
|
|
if (containerItemIdentifier == NSFileProviderItemIdentifier.rootContainer) {
|
|
@@ -281,6 +284,12 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
var localEtag = ""
|
|
|
var localEtagFPE = ""
|
|
|
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ completionHandler(NSFileProviderError(.notAuthenticated))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
guard let metadata = getTableMetadataFromItemIdentifier(identifier) else {
|
|
|
completionHandler(NSFileProviderError(.noSuchItem))
|
|
|
return
|
|
@@ -500,7 +509,13 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
|
|
|
let progress = Progress(totalUnitCount: Int64(itemIdentifiers.count))
|
|
|
var counterProgress: Int64 = 0
|
|
|
-
|
|
|
+
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ completionHandler(NSFileProviderError(.notAuthenticated))
|
|
|
+ return Progress(totalUnitCount:0)
|
|
|
+ }
|
|
|
+
|
|
|
for itemIdentifier in itemIdentifiers {
|
|
|
|
|
|
let metadata = getTableMetadataFromItemIdentifier(itemIdentifier)
|
|
@@ -565,6 +580,12 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ completionHandler(nil, NSFileProviderError(.notAuthenticated))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
guard let tableDirectory = getTableDirectoryFromParentItemIdentifier(parentItemIdentifier) else {
|
|
|
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
|
|
return
|
|
@@ -616,6 +637,12 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ completionHandler(NSFileProviderError(.notAuthenticated))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
|
guard let metadata = getTableMetadataFromItemIdentifier(itemIdentifier) else {
|
|
@@ -675,6 +702,12 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ completionHandler(nil, NSFileProviderError(.notAuthenticated))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
guard let itemFrom = try? item(for: itemIdentifier) else {
|
|
|
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
|
|
return
|
|
@@ -739,6 +772,12 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // Check account
|
|
|
+ if setupActiveAccount() == false {
|
|
|
+ completionHandler(nil, NSFileProviderError(.notAuthenticated))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
guard let metadata = getTableMetadataFromItemIdentifier(itemIdentifier) else {
|
|
|
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
|
|
return
|
|
@@ -1218,10 +1257,10 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
|
|
|
// MARK: -
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
|
|
-func setupActiveAccount() {
|
|
|
+func setupActiveAccount() -> Bool {
|
|
|
|
|
|
guard let activeAccount = NCManageDatabase.sharedInstance.getAccountActive() else {
|
|
|
- return
|
|
|
+ return false
|
|
|
}
|
|
|
|
|
|
account = activeAccount.account
|
|
@@ -1243,6 +1282,8 @@ func setupActiveAccount() {
|
|
|
} catch let error as NSError {
|
|
|
NSLog("Unable to create directory \(error.debugDescription)")
|
|
|
}
|
|
|
+
|
|
|
+ return true
|
|
|
}
|
|
|
|
|
|
func getTableMetadataFromItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) -> tableMetadata? {
|