@@ -20,7 +20,7 @@ import OSLog
20
20
21
21
@objc class FileProviderExtension : NSObject , NSFileProviderReplicatedExtension {
22
22
let domain : NSFileProviderDomain
23
- let ncKit = NextcloudKit ( )
23
+ let ncKit = NextcloudKit . shared
24
24
let appGroupIdentifier = Bundle . main. object ( forInfoDictionaryKey: " SocketApiPrefix " ) as? String
25
25
var ncAccount : Account ?
26
26
var changeObserver : RemoteChangeObserver ?
@@ -104,15 +104,20 @@ import OSLog
104
104
request _: NSFileProviderRequest ,
105
105
completionHandler: @escaping ( NSFileProviderItem ? , Error ? ) -> Void
106
106
) -> Progress {
107
- if ncAccount == nil {
107
+ guard let ncAccount else {
108
108
Logger . fileProviderExtension. error (
109
109
"""
110
110
Not fetching item for identifier: \( identifier. rawValue, privacy: . public)
111
111
as account not set up yet.
112
112
"""
113
113
)
114
114
completionHandler ( nil , NSFileProviderError ( . notAuthenticated) )
115
- } else if let item = Item . storedItem ( identifier: identifier, remoteInterface: ncKit) {
115
+ return Progress ( )
116
+ }
117
+
118
+ if let item = Item . storedItem (
119
+ identifier: identifier, account: ncAccount, remoteInterface: ncKit
120
+ ) {
116
121
completionHandler ( item, nil )
117
122
} else {
118
123
completionHandler ( nil , NSFileProviderError ( . noSuchItem) )
@@ -147,7 +152,7 @@ import OSLog
147
152
return Progress ( )
148
153
}
149
154
150
- guard ncAccount != nil else {
155
+ guard let ncAccount else {
151
156
Logger . fileProviderExtension. error (
152
157
"""
153
158
Not fetching contents for item: \( itemIdentifier. rawValue, privacy: . public)
@@ -159,7 +164,9 @@ import OSLog
159
164
return Progress ( )
160
165
}
161
166
162
- guard let item = Item . storedItem ( identifier: itemIdentifier, remoteInterface: ncKit) else {
167
+ guard let item = Item . storedItem (
168
+ identifier: itemIdentifier, account: ncAccount, remoteInterface: ncKit
169
+ ) else {
163
170
Logger . fileProviderExtension. error (
164
171
"""
165
172
Not fetching contents for item: \( itemIdentifier. rawValue, privacy: . public)
@@ -228,6 +235,7 @@ import OSLog
228
235
contents: url,
229
236
request: request,
230
237
domain: self . domain,
238
+ account: ncAccount,
231
239
remoteInterface: ncKit,
232
240
progress: progress
233
241
)
@@ -283,7 +291,9 @@ import OSLog
283
291
return Progress ( )
284
292
}
285
293
286
- guard let existingItem = Item . storedItem ( identifier: identifier, remoteInterface: ncKit) else {
294
+ guard let existingItem = Item . storedItem (
295
+ identifier: identifier, account: ncAccount, remoteInterface: ncKit
296
+ ) else {
287
297
Logger . fileProviderExtension. error (
288
298
" Not modifying item: \( ocId, privacy: . public) as item not found. "
289
299
)
@@ -331,7 +341,7 @@ import OSLog
331
341
" Received delete request for item: \( identifier. rawValue, privacy: . public) "
332
342
)
333
343
334
- guard ncAccount != nil else {
344
+ guard let ncAccount else {
335
345
Logger . fileProviderExtension. error (
336
346
" Not deleting item \( identifier. rawValue, privacy: . public) , account not set up yet "
337
347
)
@@ -340,7 +350,9 @@ import OSLog
340
350
return Progress ( )
341
351
}
342
352
343
- guard let item = Item . storedItem ( identifier: identifier, remoteInterface: ncKit) else {
353
+ guard let item = Item . storedItem (
354
+ identifier: identifier, account: ncAccount, remoteInterface: ncKit
355
+ ) else {
344
356
Logger . fileProviderExtension. error (
345
357
" Not deleting item \( identifier. rawValue, privacy: . public) , item not found "
346
358
)
@@ -359,7 +371,7 @@ import OSLog
359
371
removeSyncAction ( actionId)
360
372
}
361
373
progress. completedUnitCount = 1
362
- completionHandler ( await item . delete ( ) )
374
+ completionHandler ( error )
363
375
}
364
376
return progress
365
377
}
@@ -376,6 +388,7 @@ import OSLog
376
388
377
389
return Enumerator (
378
390
enumeratedItemIdentifier: containerItemIdentifier,
391
+ account: ncAccount,
379
392
remoteInterface: ncKit,
380
393
domain: domain,
381
394
fastEnumeration: config. fastEnumerationEnabled,
0 commit comments