From 297124eedbab683662cf617dd272c984286dfc64 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 3 Nov 2019 21:21:15 -0800 Subject: [PATCH] Use relative path when running ffprobe. Avoids problems where directory name starts with something that looks like and unknown protocol, i.e. 'AVP: Alien vs. Predator (2004)' --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1915579..dc261df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -234,7 +234,7 @@ pub struct MovieLibrary { root: String, } -fn json_metadata_for_path>(path: P) -> Result { +fn json_metadata_for_path + AsRef>(path: P) -> Result { let mut cmd = Command::new("ffprobe"); // TODO(wathiede): maybe add "-select_streams v" cmd.args(&[ @@ -245,8 +245,9 @@ fn json_metadata_for_path>(path: P) -> Result { "-show_format", "-show_error", "-show_streams", + "-i", ]) - .arg(path); + .arg(Path::new("./").join(path)); info!(target: "json", "cmd {:?}", cmd); let output = cmd.output()?; if output.status.success() { @@ -385,6 +386,9 @@ impl MovieLibrary { pub fn update_metadata(&self) -> Result, Error> { let path = Path::new(&self.root).join(FULL_METADATA_FILENAME); + // TODO(wathiede): if we fail to parse the old file (i.e. file not found), create an empty + // old_metadata and keep going. + // Open the file in read-only mode with buffer. let f = File::open(&path).context(format!("open {}", path.display()))?; let r = BufReader::new(f);