|
1 | 1 | use std::borrow::Cow; |
2 | 2 | use std::io::{self, Write}; |
3 | 3 |
|
4 | | -use base64::{engine::general_purpose, Engine as _}; |
| 4 | +use base64::{prelude::BASE64_STANDARD, Engine as _}; |
5 | 5 | use jiff::Timestamp; |
6 | 6 | use lscolors::{Indicator, LsColors, Style}; |
7 | 7 |
|
@@ -269,7 +269,7 @@ impl<'a, W: Write> Printer<'a, W> { |
269 | 269 | writeln!( |
270 | 270 | self.stdout, |
271 | 271 | "path_base64: \"{}\"", |
272 | | - general_purpose::STANDARD.encode(bytes) |
| 272 | + BASE64_STANDARD.encode(bytes) |
273 | 273 | )?; |
274 | 274 | } |
275 | 275 | } |
@@ -316,7 +316,7 @@ impl<'a, W: Write> Printer<'a, W> { |
316 | 316 | write!( |
317 | 317 | self.stdout, |
318 | 318 | "\"path_b64\":\"{}\"", |
319 | | - general_purpose::STANDARD.encode(path_bytes) |
| 319 | + BASE64_STANDARD.encode(path_bytes) |
320 | 320 | )?; |
321 | 321 | } |
322 | 322 | } |
@@ -346,16 +346,7 @@ impl<'a, W: Write> Printer<'a, W> { |
346 | 346 | let encoded_path = encode_path(path); |
347 | 347 | let metadata = entry.metadata(); |
348 | 348 |
|
349 | | - let mut detail = FileDetail { |
350 | | - path: encoded_path, |
351 | | - file_type: "unknown".to_string(), |
352 | | - size: None, |
353 | | - mode: None, |
354 | | - modified: None, |
355 | | - accessed: None, |
356 | | - created: None, |
357 | | - }; |
358 | | - if let Some(meta) = metadata { |
| 349 | + let detail = if let Some(meta) = metadata { |
359 | 350 | let size = meta.len(); |
360 | 351 | let mode = { |
361 | 352 | #[cfg(unix)] |
@@ -393,14 +384,26 @@ impl<'a, W: Write> Printer<'a, W> { |
393 | 384 | .and_then(|d| Timestamp::from_second(d.as_secs() as i64).ok()) |
394 | 385 | }); |
395 | 386 |
|
396 | | - detail.file_type = ft; |
397 | | - detail.size = Some(size); |
398 | | - detail.mode = mode; |
399 | | - detail.modified = modified; |
400 | | - detail.accessed = accessed; |
401 | | - detail.created = created; |
402 | | - } |
403 | | - |
| 387 | + FileDetail { |
| 388 | + path: encoded_path, |
| 389 | + file_type: ft, |
| 390 | + size: Some(size), |
| 391 | + mode, |
| 392 | + modified, |
| 393 | + accessed, |
| 394 | + created, |
| 395 | + } |
| 396 | + } else { |
| 397 | + FileDetail { |
| 398 | + path: encoded_path, |
| 399 | + file_type: "unknown".to_string(), |
| 400 | + size: None, |
| 401 | + mode: None, |
| 402 | + modified: None, |
| 403 | + accessed: None, |
| 404 | + created: None, |
| 405 | + } |
| 406 | + }; |
404 | 407 | match format { |
405 | 408 | OutputFormat::Json => self.print_entry_json_obj(&detail, true), |
406 | 409 | OutputFormat::Ndjson => self.print_entry_json_obj(&detail, false), |
|
0 commit comments