@@ -34,51 +34,18 @@ extension Item {
3434 let modifiedItem = self
3535 var contentsLocation = newContents
3636 if contentsLocation == nil {
37- assert ( domain != nil , " The domain should not be nil! " )
38- guard let manager = NSFileProviderManager ( for: domain!) ,
39- let fileUrl = try ? await manager. getUserVisibleURL (
40- for: modifiedItem. itemIdentifier
41- )
42- else {
37+ assert ( domain != nil )
38+ guard let domain, let localUrl = await localUrlForContents ( domain: domain) else {
4339 Self . logger. error (
4440 """
4541 Unable to upload modified item that was previously ignored.
4642 filename: \( modifiedItem. filename, privacy: . public)
47- Unable to get a file provider manager for the given domain, or item URL
43+ local url for contents could not be acquired.
4844 """
4945 )
5046 return ( nil , NSFileProviderError ( . cannotSynchronize) )
5147 }
52- let fm = FileManager . default
53- let tempLocation = fm. temporaryDirectory. appendingPathComponent ( UUID ( ) . uuidString)
54- let coordinator = NSFileCoordinator ( )
55- var readData : Data ?
56- coordinator. coordinate ( readingItemAt: fileUrl, options: [ ] , error: nil ) { readURL in
57- readData = try ? Data ( contentsOf: readURL)
58- }
59- guard let readData else {
60- Self . logger. error (
61- """
62- Unable to upload modified item that was previously ignored.
63- filename: \( modifiedItem. filename, privacy: . public)
64- Unable to get ignored file item data from URL
65- """
66- )
67- return ( nil , NSFileProviderError ( . cannotSynchronize) )
68- }
69- do {
70- try readData. write ( to: tempLocation)
71- } catch let error {
72- Self . logger. error (
73- """
74- Unable to upload modified item that was previously ignored.
75- filename: \( modifiedItem. filename, privacy: . public)
76- Unable to write ignored file item contents to temp location.
77- error: \( error. localizedDescription, privacy: . public)
78- """
79- )
80- }
81- contentsLocation = tempLocation
48+ contentsLocation = localUrl
8249 }
8350 return await Self . create (
8451 basedOn: itemTarget,
0 commit comments