@@ -99,14 +99,8 @@ impl<'a> Transaction<'a> {
9999 /// Remove a file from a relative path to the install prefix.
100100 pub fn remove_file ( & mut self , component : & str , relpath : PathBuf ) -> Result < ( ) > {
101101 assert ! ( relpath. is_relative( ) ) ;
102- let item = ChangedItem :: remove_file (
103- & self . prefix ,
104- component,
105- relpath,
106- self . tmp_cx ,
107- self . notify_handler ( ) ,
108- self . process ,
109- ) ?;
102+ let item =
103+ ChangedItem :: remove_file ( & self . prefix , component, relpath, self . tmp_cx , self . process ) ?;
110104 self . change ( item) ;
111105 Ok ( ( ) )
112106 }
@@ -115,14 +109,8 @@ impl<'a> Transaction<'a> {
115109 /// install prefix.
116110 pub fn remove_dir ( & mut self , component : & str , relpath : PathBuf ) -> Result < ( ) > {
117111 assert ! ( relpath. is_relative( ) ) ;
118- let item = ChangedItem :: remove_dir (
119- & self . prefix ,
120- component,
121- relpath,
122- self . tmp_cx ,
123- self . notify_handler ( ) ,
124- self . process ,
125- ) ?;
112+ let item =
113+ ChangedItem :: remove_dir ( & self . prefix , component, relpath, self . tmp_cx , self . process ) ?;
126114 self . change ( item) ;
127115 Ok ( ( ) )
128116 }
@@ -161,39 +149,22 @@ impl<'a> Transaction<'a> {
161149 src : & Path ,
162150 ) -> Result < ( ) > {
163151 assert ! ( relpath. is_relative( ) ) ;
164- let item = ChangedItem :: move_file (
165- & self . prefix ,
166- component,
167- relpath,
168- src,
169- self . notify_handler ( ) ,
170- self . process ,
171- ) ?;
152+ let item = ChangedItem :: move_file ( & self . prefix , component, relpath, src, self . process ) ?;
172153 self . change ( item) ;
173154 Ok ( ( ) )
174155 }
175156
176157 /// Recursively move a directory to a relative path of the install prefix.
177158 pub ( crate ) fn move_dir ( & mut self , component : & str , relpath : PathBuf , src : & Path ) -> Result < ( ) > {
178159 assert ! ( relpath. is_relative( ) ) ;
179- let item = ChangedItem :: move_dir (
180- & self . prefix ,
181- component,
182- relpath,
183- src,
184- self . notify_handler ( ) ,
185- self . process ,
186- ) ?;
160+ let item = ChangedItem :: move_dir ( & self . prefix , component, relpath, src, self . process ) ?;
187161 self . change ( item) ;
188162 Ok ( ( ) )
189163 }
190164
191165 pub ( crate ) fn temp ( & self ) -> & ' a temp:: Context {
192166 self . tmp_cx
193167 }
194- pub ( crate ) fn notify_handler ( & self ) -> & ' a dyn Fn ( Notification < ' _ > ) {
195- self . notify_handler
196- }
197168}
198169
199170/// If a Transaction is dropped without being committed, the changes
@@ -205,7 +176,7 @@ impl Drop for Transaction<'_> {
205176 for item in self . changes . iter ( ) . rev ( ) {
206177 // ok_ntfy!(self.notify_handler,
207178 // Notification::NonFatalError,
208- match item. roll_back ( & self . prefix , self . notify_handler ( ) , self . process ) {
179+ match item. roll_back ( & self . prefix , self . process ) {
209180 Ok ( ( ) ) => { }
210181 Err ( e) => {
211182 ( self . notify_handler ) ( Notification :: NonFatalError ( & e) ) ;
@@ -230,24 +201,18 @@ enum ChangedItem<'a> {
230201}
231202
232203impl < ' a > ChangedItem < ' a > {
233- fn roll_back (
234- & self ,
235- prefix : & InstallPrefix ,
236- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
237- process : & Process ,
238- ) -> Result < ( ) > {
204+ fn roll_back ( & self , prefix : & InstallPrefix , process : & Process ) -> Result < ( ) > {
239205 use self :: ChangedItem :: * ;
240206 match self {
241207 AddedFile ( path) => utils:: remove_file ( "component" , & prefix. abs_path ( path) ) ?,
242208 AddedDir ( path) => utils:: remove_dir ( "component" , & prefix. abs_path ( path) ) ?,
243209 RemovedFile ( path, tmp) | ModifiedFile ( path, Some ( tmp) ) => {
244- utils:: rename ( "component" , tmp, & prefix. abs_path ( path) , notify , process) ?
210+ utils:: rename ( "component" , tmp, & prefix. abs_path ( path) , process) ?
245211 }
246212 RemovedDir ( path, tmp) => utils:: rename (
247213 "component" ,
248214 & tmp. join ( "bk" ) ,
249215 & prefix. abs_path ( path) ,
250- notify,
251216 process,
252217 ) ?,
253218 ModifiedFile ( path, None ) => {
@@ -304,7 +269,6 @@ impl<'a> ChangedItem<'a> {
304269 component : & str ,
305270 relpath : PathBuf ,
306271 tmp_cx : & ' a temp:: Context ,
307- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
308272 process : & Process ,
309273 ) -> Result < Self > {
310274 let abs_path = prefix. abs_path ( & relpath) ;
@@ -316,7 +280,7 @@ impl<'a> ChangedItem<'a> {
316280 }
317281 . into ( ) )
318282 } else {
319- utils:: rename ( "component" , & abs_path, & backup, notify , process) ?;
283+ utils:: rename ( "component" , & abs_path, & backup, process) ?;
320284 Ok ( ChangedItem :: RemovedFile ( relpath, backup) )
321285 }
322286 }
@@ -325,7 +289,6 @@ impl<'a> ChangedItem<'a> {
325289 component : & str ,
326290 relpath : PathBuf ,
327291 tmp_cx : & ' a temp:: Context ,
328- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
329292 process : & Process ,
330293 ) -> Result < Self > {
331294 let abs_path = prefix. abs_path ( & relpath) ;
@@ -337,7 +300,7 @@ impl<'a> ChangedItem<'a> {
337300 }
338301 . into ( ) )
339302 } else {
340- utils:: rename ( "component" , & abs_path, & backup. join ( "bk" ) , notify , process) ?;
303+ utils:: rename ( "component" , & abs_path, & backup. join ( "bk" ) , process) ?;
341304 Ok ( ChangedItem :: RemovedDir ( relpath, backup) )
342305 }
343306 }
@@ -364,23 +327,21 @@ impl<'a> ChangedItem<'a> {
364327 component : & str ,
365328 relpath : PathBuf ,
366329 src : & Path ,
367- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
368330 process : & Process ,
369331 ) -> Result < Self > {
370332 let abs_path = ChangedItem :: dest_abs_path ( prefix, component, & relpath) ?;
371- utils:: rename ( "component" , src, & abs_path, notify , process) ?;
333+ utils:: rename ( "component" , src, & abs_path, process) ?;
372334 Ok ( ChangedItem :: AddedFile ( relpath) )
373335 }
374336 fn move_dir (
375337 prefix : & InstallPrefix ,
376338 component : & str ,
377339 relpath : PathBuf ,
378340 src : & Path ,
379- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
380341 process : & Process ,
381342 ) -> Result < Self > {
382343 let abs_path = ChangedItem :: dest_abs_path ( prefix, component, & relpath) ?;
383- utils:: rename ( "component" , src, & abs_path, notify , process) ?;
344+ utils:: rename ( "component" , src, & abs_path, process) ?;
384345 Ok ( ChangedItem :: AddedDir ( relpath) )
385346 }
386347}
0 commit comments