Print suggested empty directory cleanup and clean lint.

This commit is contained in:
Bill Thiede 2020-06-07 16:38:38 -07:00
parent 18108b5d44
commit d00d49135a
2 changed files with 3 additions and 13 deletions

View File

@ -329,17 +329,6 @@ impl Movie {
})) }))
} }
} }
fn min_resolution(&self) -> Option<Resolution> {
if self.files.is_empty() {
None
} else {
Some(self.files.iter().fold(
Resolution(usize::max_value(), usize::max_value()),
|acc, (_, cmd)| std::cmp::min(acc, cmd.largest_dimension().unwrap()),
))
}
}
} }
impl Display for Movie { impl Display for Movie {
@ -671,7 +660,7 @@ impl MovieLibrary {
Ok(movies_from_paths_compact_metadata(p_cmd)) Ok(movies_from_paths_compact_metadata(p_cmd))
} }
pub fn videos(&self) -> Result<(HashMap<String, CompactMetadata>), Error> { pub fn videos(&self) -> Result<HashMap<String, CompactMetadata>, Error> {
let path = Path::new(&self.root).join(COMPACT_METADATA_FILENAME); let path = Path::new(&self.root).join(COMPACT_METADATA_FILENAME);
let f = File::open(&path).context(format!("open {}", path.display()))?; let f = File::open(&path).context(format!("open {}", path.display()))?;
let r = BufReader::new(f); let r = BufReader::new(f);

View File

@ -261,10 +261,11 @@ fn main() -> Result<(), Box<dyn Error>> {
Command::EmptyDirs => { Command::EmptyDirs => {
let lib = MovieLibrary::new(MOVIE_DIR); let lib = MovieLibrary::new(MOVIE_DIR);
let dirs = lib.empty_dirs()?; let dirs = lib.empty_dirs()?;
let root = Path::new(&lib.root);
if !dirs.is_empty() { if !dirs.is_empty() {
println!("Empty directories:"); println!("Empty directories:");
for d in dirs { for d in dirs {
println!(" {}", d); println!(r#"rm -rf "{}""#, root.join(d).to_string_lossy());
} }
} }
} }