Skip to content

Commit

Permalink
Clean up file provider extension property declarations and init
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Feb 5, 2024
1 parent 33735a9 commit 3c4bf34
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,17 @@ import OSLog
class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKCommonDelegate {
let domain: NSFileProviderDomain
let ncKit = NextcloudKit()
lazy var ncKitBackground: NKBackground = {
let nckb = NKBackground(nkCommonInstance: ncKit.nkCommonInstance)
return nckb
}()

let appGroupIdentifier: String? =
Bundle.main.object(forInfoDictionaryKey: "SocketApiPrefix") as? String
let appGroupIdentifier = Bundle.main.object(forInfoDictionaryKey: "SocketApiPrefix") as? String
var ncAccount: NextcloudAccount?
lazy var ncKitBackground = NKBackground(nkCommonInstance: ncKit.nkCommonInstance)
lazy var socketClient: LocalSocketClient? = {
guard let containerUrl = pathForAppGroupContainer() else {
Logger.fileProviderExtension.critical(
"Could not start file provider socket client properly as could not get container url"
)
Logger.fileProviderExtension.critical("Won't start client, no container url")
return nil
}

let socketPath = containerUrl.appendingPathComponent(
".fileprovidersocket", conformingTo: .archive)
let lineProcessor = FileProviderSocketLineProcessor(delegate: self)

return LocalSocketClient(socketPath: socketPath.path, lineProcessor: lineProcessor)
}()

Expand All @@ -61,9 +52,11 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
}()

required init(domain: NSFileProviderDomain) {
// The containing application must create a domain using
// `NSFileProviderManager.add(_:, completionHandler:)`. The system will then launch the
// application extension process, call `FileProviderExtension.init(domain:)` to instantiate
// the extension for that domain, and call methods on the instance.
self.domain = domain
// The containing application must create a domain using `NSFileProviderManager.add(_:, completionHandler:)`. The system will then launch the application extension process, call `FileProviderExtension.init(domain:)` to instantiate the extension for that domain, and call methods on the instance.

super.init()
socketClient?.start()
}
Expand Down

0 comments on commit 3c4bf34

Please sign in to comment.