@@ -94,18 +94,16 @@ pub enum SnapshotError {
94
94
impl Snapshotter for CompressedArchiveSnapshotter {
95
95
fn snapshot ( & self , archive_name : & str ) -> StdResult < OngoingSnapshot > {
96
96
let archive_path = self . ongoing_snapshot_directory . join ( archive_name) ;
97
- let filesize = self . create_and_verify_archive ( & archive_path) . map_err ( |err | {
97
+ let filesize = self . create_and_verify_archive ( & archive_path) . inspect_err ( |_err | {
98
98
if archive_path. exists ( ) {
99
- if let Err ( remove_error) = std :: fs:: remove_file ( & archive_path) {
99
+ if let Err ( remove_error) = fs:: remove_file ( & archive_path) {
100
100
warn ! (
101
101
" > Post snapshotter.snapshot failure, could not remove temporary archive at path: path:{}, err: {}" ,
102
102
archive_path. display( ) ,
103
103
remove_error
104
104
) ;
105
105
}
106
106
}
107
-
108
- err
109
107
} ) . with_context ( || format ! ( "CompressedArchiveSnapshotter can not create and verify archive: '{}'" , archive_path. display( ) ) ) ?;
110
108
111
109
Ok ( OngoingSnapshot {
@@ -123,15 +121,15 @@ impl CompressedArchiveSnapshotter {
123
121
compression_algorithm : SnapshotterCompressionAlgorithm ,
124
122
) -> StdResult < CompressedArchiveSnapshotter > {
125
123
if ongoing_snapshot_directory. exists ( ) {
126
- std :: fs:: remove_dir_all ( & ongoing_snapshot_directory) . with_context ( || {
124
+ fs:: remove_dir_all ( & ongoing_snapshot_directory) . with_context ( || {
127
125
format ! (
128
126
"Can not remove snapshotter directory: '{}'." ,
129
127
ongoing_snapshot_directory. display( )
130
128
)
131
129
} ) ?;
132
130
}
133
131
134
- std :: fs:: create_dir ( & ongoing_snapshot_directory) . map_err ( |e| {
132
+ fs:: create_dir ( & ongoing_snapshot_directory) . map_err ( |e| {
135
133
DependenciesBuilderError :: Initialization {
136
134
message : format ! (
137
135
"Can not create snapshotter directory: '{}'." ,
@@ -149,7 +147,7 @@ impl CompressedArchiveSnapshotter {
149
147
}
150
148
151
149
fn get_file_size ( filepath : & Path ) -> StdResult < u64 > {
152
- let res = std :: fs:: metadata ( filepath)
150
+ let res = fs:: metadata ( filepath)
153
151
. map_err ( |e| SnapshotError :: GeneralError ( e. to_string ( ) ) ) ?
154
152
. len ( ) ;
155
153
Ok ( res)
@@ -456,12 +454,7 @@ mod tests {
456
454
. unwrap ( ) ,
457
455
) ;
458
456
459
- assert_eq ! (
460
- 0 ,
461
- std:: fs:: read_dir( pending_snapshot_directory)
462
- . unwrap( )
463
- . count( )
464
- ) ;
457
+ assert_eq ! ( 0 , fs:: read_dir( pending_snapshot_directory) . unwrap( ) . count( ) ) ;
465
458
}
466
459
467
460
#[ test]
@@ -487,7 +480,7 @@ mod tests {
487
480
let _ = snapshotter
488
481
. snapshot ( "whatever.tar.gz" )
489
482
. expect_err ( "Snapshotter::snapshot should fail if the db is empty." ) ;
490
- let remaining_files: Vec < String > = std :: fs:: read_dir ( & pending_snapshot_directory)
483
+ let remaining_files: Vec < String > = fs:: read_dir ( & pending_snapshot_directory)
491
484
. unwrap ( )
492
485
. map ( |f| f. unwrap ( ) . file_name ( ) . to_str ( ) . unwrap ( ) . to_owned ( ) )
493
486
. collect ( ) ;
0 commit comments