Compare commits

..

3 Commits

Author SHA1 Message Date
3a61e15449 Latest lock. 2022-07-23 21:06:49 -07:00
c46ae525fc Just remove dupes, don't move them. 2022-07-23 21:06:22 -07:00
e16d899c14 Update tests to match intended behavior. 2022-07-23 21:06:03 -07:00
3 changed files with 245 additions and 255 deletions

463
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,6 @@
use std::collections::HashMap; use std::{collections::HashMap, error::Error, io::Write, path::Path, time::Duration};
use std::error::Error;
use std::io::Write;
use std::path::Path;
use std::time::Duration;
use human_format::Formatter; use human_format::{Formatter, Scales};
use human_format::Scales;
use humantime; use humantime;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use log::info; use log::info;
@ -13,9 +8,7 @@ use regex::Regex;
use structopt::StructOpt; use structopt::StructOpt;
use tabwriter::TabWriter; use tabwriter::TabWriter;
use superdeduper::clean_path_parent; use superdeduper::{clean_path_parent, CompactMetadata, MovieLibrary};
use superdeduper::CompactMetadata;
use superdeduper::MovieLibrary;
const MOVIE_DIR: &str = "/home/wathiede/Movies"; const MOVIE_DIR: &str = "/home/wathiede/Movies";
const TO_BE_REMOVED_DIR: &str = "/home/wathiede/to-be-deleted/"; const TO_BE_REMOVED_DIR: &str = "/home/wathiede/to-be-deleted/";
@ -71,11 +64,7 @@ fn print_dupes(lib: &MovieLibrary) {
delete_paths.sort(); delete_paths.sort();
let root = Path::new(&lib.root); let root = Path::new(&lib.root);
for path in &delete_paths { for path in &delete_paths {
println!( println!(r#"rm "{}""#, root.join(path).to_string_lossy(),);
r#"mv "{}" {}"#,
root.join(path).to_string_lossy(),
TO_BE_REMOVED_DIR
);
} }
if delete_paths.len() > 0 { if delete_paths.len() > 0 {
println!("superdeduper update-compact-metadata && superdeduper empty-dirs") println!("superdeduper update-compact-metadata && superdeduper empty-dirs")
@ -154,7 +143,7 @@ fn print_videos(videos: &HashMap<String, CompactMetadata>, filter: Option<&Regex
humantime::Duration::from(Duration::from_secs(md.duration as u64)), humantime::Duration::from(Duration::from_secs(md.duration as u64)),
&name[MOVIE_DIR.len() + 1..] &name[MOVIE_DIR.len() + 1..]
); );
println!("mv '{}' '{}'", name, TO_BE_REMOVED_DIR); println!("rm '{}'", name);
} }
} }

View File

@ -335,7 +335,7 @@ fn test_fullmetal() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
fn test_keep_lower_res_higher_bit_rate() -> Result<(), Box<dyn Error>> { fn test_keep_higher_res_lower_bit_rate() -> Result<(), Box<dyn Error>> {
let mut movies = Movies { let mut movies = Movies {
movies: vec![ movies: vec![
build_movie(vec![( build_movie(vec![(
@ -361,15 +361,17 @@ fn test_keep_lower_res_higher_bit_rate() -> Result<(), Box<dyn Error>> {
let got = movies.duplicate_candidates(); let got = movies.duplicate_candidates();
let want = vec![( let want = vec![(
build_movie(vec![( build_movie(vec![(
"X Men The Last Stand (2006)/X.Men.The.Last.Stand.2006.1080p.BluRay.x264.DTS-ES.PRoDJi.mkv",
(1920, 800),
11349705,
)]),
vec![build_movie(vec![(
"X Men The Last Stand (2006)/948f08a4ba784626ac13de77b77559dd.mkv", "X Men The Last Stand (2006)/948f08a4ba784626ac13de77b77559dd.mkv",
(1920, 1080), (1920, 1080),
6574160, 6574160,
)])], )]),
vec![
build_movie(vec![(
"X Men The Last Stand (2006)/X.Men.The.Last.Stand.2006.1080p.BluRay.x264.DTS-ES.PRoDJi.mkv",
(1920, 800),
11349705,
)])
],
)]; )];
validate_duplicates(got, want); validate_duplicates(got, want);
Ok(()) Ok(())