@@ -99,14 +99,8 @@ impl<'a> Transaction<'a> {
99
99
/// Remove a file from a relative path to the install prefix.
100
100
pub fn remove_file ( & mut self , component : & str , relpath : PathBuf ) -> Result < ( ) > {
101
101
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 ) ?;
110
104
self . change ( item) ;
111
105
Ok ( ( ) )
112
106
}
@@ -115,14 +109,8 @@ impl<'a> Transaction<'a> {
115
109
/// install prefix.
116
110
pub fn remove_dir ( & mut self , component : & str , relpath : PathBuf ) -> Result < ( ) > {
117
111
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 ) ?;
126
114
self . change ( item) ;
127
115
Ok ( ( ) )
128
116
}
@@ -161,39 +149,22 @@ impl<'a> Transaction<'a> {
161
149
src : & Path ,
162
150
) -> Result < ( ) > {
163
151
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 ) ?;
172
153
self . change ( item) ;
173
154
Ok ( ( ) )
174
155
}
175
156
176
157
/// Recursively move a directory to a relative path of the install prefix.
177
158
pub ( crate ) fn move_dir ( & mut self , component : & str , relpath : PathBuf , src : & Path ) -> Result < ( ) > {
178
159
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 ) ?;
187
161
self . change ( item) ;
188
162
Ok ( ( ) )
189
163
}
190
164
191
165
pub ( crate ) fn temp ( & self ) -> & ' a temp:: Context {
192
166
self . tmp_cx
193
167
}
194
- pub ( crate ) fn notify_handler ( & self ) -> & ' a dyn Fn ( Notification < ' _ > ) {
195
- self . notify_handler
196
- }
197
168
}
198
169
199
170
/// If a Transaction is dropped without being committed, the changes
@@ -205,7 +176,7 @@ impl Drop for Transaction<'_> {
205
176
for item in self . changes . iter ( ) . rev ( ) {
206
177
// ok_ntfy!(self.notify_handler,
207
178
// Notification::NonFatalError,
208
- match item. roll_back ( & self . prefix , self . notify_handler ( ) , self . process ) {
179
+ match item. roll_back ( & self . prefix , self . process ) {
209
180
Ok ( ( ) ) => { }
210
181
Err ( e) => {
211
182
( self . notify_handler ) ( Notification :: NonFatalError ( & e) ) ;
@@ -230,24 +201,18 @@ enum ChangedItem<'a> {
230
201
}
231
202
232
203
impl < ' 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 < ( ) > {
239
205
use self :: ChangedItem :: * ;
240
206
match self {
241
207
AddedFile ( path) => utils:: remove_file ( "component" , & prefix. abs_path ( path) ) ?,
242
208
AddedDir ( path) => utils:: remove_dir ( "component" , & prefix. abs_path ( path) ) ?,
243
209
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) ?
245
211
}
246
212
RemovedDir ( path, tmp) => utils:: rename (
247
213
"component" ,
248
214
& tmp. join ( "bk" ) ,
249
215
& prefix. abs_path ( path) ,
250
- notify,
251
216
process,
252
217
) ?,
253
218
ModifiedFile ( path, None ) => {
@@ -304,7 +269,6 @@ impl<'a> ChangedItem<'a> {
304
269
component : & str ,
305
270
relpath : PathBuf ,
306
271
tmp_cx : & ' a temp:: Context ,
307
- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
308
272
process : & Process ,
309
273
) -> Result < Self > {
310
274
let abs_path = prefix. abs_path ( & relpath) ;
@@ -316,7 +280,7 @@ impl<'a> ChangedItem<'a> {
316
280
}
317
281
. into ( ) )
318
282
} else {
319
- utils:: rename ( "component" , & abs_path, & backup, notify , process) ?;
283
+ utils:: rename ( "component" , & abs_path, & backup, process) ?;
320
284
Ok ( ChangedItem :: RemovedFile ( relpath, backup) )
321
285
}
322
286
}
@@ -325,7 +289,6 @@ impl<'a> ChangedItem<'a> {
325
289
component : & str ,
326
290
relpath : PathBuf ,
327
291
tmp_cx : & ' a temp:: Context ,
328
- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
329
292
process : & Process ,
330
293
) -> Result < Self > {
331
294
let abs_path = prefix. abs_path ( & relpath) ;
@@ -337,7 +300,7 @@ impl<'a> ChangedItem<'a> {
337
300
}
338
301
. into ( ) )
339
302
} else {
340
- utils:: rename ( "component" , & abs_path, & backup. join ( "bk" ) , notify , process) ?;
303
+ utils:: rename ( "component" , & abs_path, & backup. join ( "bk" ) , process) ?;
341
304
Ok ( ChangedItem :: RemovedDir ( relpath, backup) )
342
305
}
343
306
}
@@ -364,23 +327,21 @@ impl<'a> ChangedItem<'a> {
364
327
component : & str ,
365
328
relpath : PathBuf ,
366
329
src : & Path ,
367
- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
368
330
process : & Process ,
369
331
) -> Result < Self > {
370
332
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) ?;
372
334
Ok ( ChangedItem :: AddedFile ( relpath) )
373
335
}
374
336
fn move_dir (
375
337
prefix : & InstallPrefix ,
376
338
component : & str ,
377
339
relpath : PathBuf ,
378
340
src : & Path ,
379
- notify : & ' a dyn Fn ( Notification < ' _ > ) ,
380
341
process : & Process ,
381
342
) -> Result < Self > {
382
343
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) ?;
384
345
Ok ( ChangedItem :: AddedDir ( relpath) )
385
346
}
386
347
}
0 commit comments