@@ -27,12 +27,13 @@ extension CoreDataRepository {
2727 transactionAuthor: String ? = nil
2828 ) async -> Result < Model , CoreDataRepositoryError > {
2929 await context. performInScratchPad ( schedule: . enqueued) { [ context] scratchPad in
30- scratchPad. transactionAuthor = transactionAuthor
3130 let object = Model . RepoManaged ( context: scratchPad)
3231 object. create ( from: item)
3332 try scratchPad. save ( )
3433 try context. performAndWait {
34+ context. transactionAuthor = transactionAuthor
3535 try context. save ( )
36+ context. transactionAuthor = nil
3637 }
3738 try scratchPad. obtainPermanentIDs ( for: [ object] )
3839 return object. asUnmanaged
@@ -70,16 +71,19 @@ extension CoreDataRepository {
7071 public func update< Model: UnmanagedModel > (
7172 _ url: URL ,
7273 with item: Model ,
73- transactionAuthor _ : String ? = nil
74+ transactionAuthor: String ? = nil
7475 ) async -> Result < Model , CoreDataRepositoryError > {
7576 await context. performInScratchPad ( schedule: . enqueued) { [ context] scratchPad in
77+ scratchPad. transactionAuthor = transactionAuthor
7678 let id = try scratchPad. tryObjectId ( from: url)
7779 let object = try scratchPad. notDeletedObject ( for: id)
7880 let repoManaged : Model . RepoManaged = try object. asRepoManaged ( )
7981 repoManaged. update ( from: item)
8082 try scratchPad. save ( )
8183 try context. performAndWait {
84+ context. transactionAuthor = transactionAuthor
8285 try context. save ( )
86+ context. transactionAuthor = nil
8387 }
8488 return repoManaged. asUnmanaged
8589 }
@@ -97,16 +101,19 @@ extension CoreDataRepository {
97101 ///
98102 public func delete(
99103 _ url: URL ,
100- transactionAuthor _ : String ? = nil
104+ transactionAuthor: String ? = nil
101105 ) async -> Result < Void , CoreDataRepositoryError > {
102106 await context. performInScratchPad ( schedule: . enqueued) { [ context] scratchPad in
107+ scratchPad. transactionAuthor = transactionAuthor
103108 let id = try scratchPad. tryObjectId ( from: url)
104109 let object = try scratchPad. notDeletedObject ( for: id)
105110 object. prepareForDeletion ( )
106111 scratchPad. delete ( object)
107112 try scratchPad. save ( )
108113 try context. performAndWait {
114+ context. transactionAuthor = transactionAuthor
109115 try context. save ( )
116+ context. transactionAuthor = nil
110117 }
111118 return ( )
112119 }
0 commit comments