mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
Complete FileProviderEnumerator init, get correct serverUrl for enumerator item identifier
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
fa7e441d81
commit
9f6c2df4e3
2 changed files with 18 additions and 2 deletions
|
@ -18,9 +18,25 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||||
|
|
||||||
private let enumeratedItemIdentifier: NSFileProviderItemIdentifier
|
private let enumeratedItemIdentifier: NSFileProviderItemIdentifier
|
||||||
private let anchor = NSFileProviderSyncAnchor("an anchor".data(using: .utf8)!)
|
private let anchor = NSFileProviderSyncAnchor("an anchor".data(using: .utf8)!)
|
||||||
|
let ncAccount: NextcloudAccount
|
||||||
|
var serverUrl: URL?
|
||||||
|
|
||||||
init(enumeratedItemIdentifier: NSFileProviderItemIdentifier) {
|
init(enumeratedItemIdentifier: NSFileProviderItemIdentifier, ncAccount: NextcloudAccount) {
|
||||||
self.enumeratedItemIdentifier = enumeratedItemIdentifier
|
self.enumeratedItemIdentifier = enumeratedItemIdentifier
|
||||||
|
self.ncAccount = ncAccount
|
||||||
|
|
||||||
|
if enumeratedItemIdentifier == .rootContainer {
|
||||||
|
self.serverUrl = ncAccount.serverUrl
|
||||||
|
} else {
|
||||||
|
let dbManager = NextcloudFilesDatabaseManager.shared
|
||||||
|
if let itemMetadata = dbManager.fileMetadataFromFileProviderItemIdentifier(enumeratedItemIdentifier),
|
||||||
|
let itemDirectoryMetadata = dbManager.directoryMetadataForFile(itemMetadata) {
|
||||||
|
|
||||||
|
self.serverUrl = URL(string: itemDirectoryMetadata.serverUrl + "/" + itemMetadata.fileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
func enumerator(for containerItemIdentifier: NSFileProviderItemIdentifier, request: NSFileProviderRequest) throws -> NSFileProviderEnumerator {
|
func enumerator(for containerItemIdentifier: NSFileProviderItemIdentifier, request: NSFileProviderRequest) throws -> NSFileProviderEnumerator {
|
||||||
return FileProviderEnumerator(enumeratedItemIdentifier: containerItemIdentifier)
|
return FileProviderEnumerator(enumeratedItemIdentifier: containerItemIdentifier, ncAccount: ncAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Nextcloud desktop client communication
|
// MARK: Nextcloud desktop client communication
|
||||||
|
|
Loading…
Reference in a new issue