@@ -49,27 +49,37 @@ fn main() {
49
49
walker. run ( || {
50
50
let tx = tx. clone ( ) ;
51
51
Box :: new ( move |result| {
52
- if let Ok ( entry) = result {
53
- let metadata = entry. metadata ( ) . unwrap ( ) ;
52
+ match result {
53
+ Ok ( entry) => {
54
+ if let Ok ( metadata) = entry. metadata ( ) {
55
+ // If the entry has more than one hard link, generate
56
+ // a unique ID consisting of device and inode in order
57
+ // not to count this entry twice.
58
+ let unique_id = if metadata. is_file ( ) && metadata. nlink ( ) > 1 {
59
+ Some ( ( metadata. dev ( ) , metadata. ino ( ) ) )
60
+ } else {
61
+ None
62
+ } ;
54
63
55
- // If the entry has more than one hard link, generate
56
- // a unique ID consisting of device and inode in order
57
- // not to count this entry twice.
58
- let unique_id = if metadata. is_file ( ) && metadata. nlink ( ) > 1 {
59
- Some ( ( metadata. dev ( ) , metadata. ino ( ) ) )
60
- } else {
61
- None
62
- } ;
64
+ let size = metadata. len ( ) ;
63
65
64
- let size = metadata. len ( ) ;
65
-
66
- tx. send ( ( unique_id, size) ) . unwrap ( ) ;
66
+ tx. send ( ( unique_id, size) ) . ok ( ) ;
67
+ } else {
68
+ eprintln ! (
69
+ "Could not get metadata: '{}'" ,
70
+ entry. path( ) . to_string_lossy( )
71
+ ) ;
72
+ }
73
+ }
74
+ Err ( err) => {
75
+ eprintln ! ( "I/O error: {}" , err) ;
76
+ }
67
77
}
68
78
69
79
return ignore:: WalkState :: Continue ;
70
80
} )
71
81
} ) ;
72
82
73
83
drop ( tx) ;
74
- receiver_thread. join ( ) . unwrap ( ) ;
84
+ receiver_thread. join ( ) . ok ( ) ;
75
85
}
0 commit comments