| skipped 39 lines |
40 | 40 | | Ok(modified_time.format("%Y-%m-%d %H:%M:%S").to_string()) |
41 | 41 | | } |
42 | 42 | | |
43 | | - | fn print_meta_info() { |
44 | | - | println!("Deduplicator v{}", std::env!("CARGO_PKG_VERSION")); |
45 | | - | } |
46 | | - | |
47 | 43 | | fn scan_group_instruction() -> Result<String> { |
48 | 44 | | println!("\nEnter the indices of the files you want to delete."); |
49 | 45 | | println!("You can enter multiple files using commas to seperate file indices."); |
| skipped 65 lines |
115 | 111 | | } |
116 | 112 | | |
117 | 113 | | pub fn interactive(duplicates: DashMap<String, Vec<File>>, opts: &Params) { |
118 | | - | print_meta_info(); |
119 | | - | |
120 | 114 | | if duplicates.is_empty() { |
121 | 115 | | println!( |
122 | 116 | | "\n{}", |
| skipped 5 lines |
128 | 122 | | duplicates |
129 | 123 | | .clone() |
130 | 124 | | .into_iter() |
131 | | - | .sorted_unstable_by_key(|f| { |
132 | | - | -(f.1.first().and_then(|ff| ff.size).unwrap_or_default() as i64) |
| 125 | + | .sorted_unstable_by_key(|(_, f)| { |
| 126 | + | -(f.first().and_then(|ff| ff.size).unwrap_or_default() as i64) |
133 | 127 | | }) // sort by descending file size in interactive mode |
134 | 128 | | .enumerate() |
135 | 129 | | .for_each(|(gindex, (_, group))| { |
| skipped 4 lines |
140 | 134 | | itable.add_row(row![ |
141 | 135 | | index, |
142 | 136 | | format_path(&file.path, opts).unwrap_or_default().blue(), |
143 | | - | file_size(&file).unwrap_or_default().red(), |
| 137 | + | file_size(file).unwrap_or_default().red(), |
144 | 138 | | modified_time(&file.path).unwrap_or_default().yellow() |
145 | 139 | | ]); |
146 | 140 | | }); |
| skipped 3 lines |
150 | 144 | | } |
151 | 145 | | |
152 | 146 | | pub fn print(duplicates: DashMap<String, Vec<File>>, opts: &Params) { |
153 | | - | print_meta_info(); |
154 | | - | |
155 | 147 | | if duplicates.is_empty() { |
156 | 148 | | println!( |
157 | 149 | | "\n{}", |
| skipped 6 lines |
164 | 156 | | output_table.set_titles(row!["hash", "duplicates"]); |
165 | 157 | | duplicates |
166 | 158 | | .into_iter() |
167 | | - | .sorted_unstable_by_key(|f| f.1.first().and_then(|ff| ff.size).unwrap_or_default()) // sort by ascending size |
| 159 | + | .sorted_unstable_by_key(|(_, f)| f.first().and_then(|ff| ff.size).unwrap_or_default()) |
168 | 160 | | .for_each(|(hash, group)| { |
169 | 161 | | let mut inner_table = Table::new(); |
170 | 162 | | inner_table.set_format(*format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR); |
171 | 163 | | group.iter().for_each(|file| { |
172 | 164 | | inner_table.add_row(row![ |
173 | 165 | | format_path(&file.path, opts).unwrap_or_default().blue(), |
174 | | - | file_size(&file).unwrap_or_default().red(), |
| 166 | + | file_size(file).unwrap_or_default().red(), |
175 | 167 | | modified_time(&file.path).unwrap_or_default().yellow() |
176 | 168 | | ]); |
177 | 169 | | }); |
| skipped 6 lines |