Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print a proper error message if the input file does not exist #626

Merged
merged 1 commit into from
May 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions av1an-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,24 +519,23 @@ pub(crate) fn resolve_file_paths(path: &Path) -> anyhow::Result<Box<dyn Iterator
// TODO: to validate file extensions
// let valid_media_extensions = ["mkv", "mov", "mp4", "webm", "avi", "qt", "ts", "m2t", "py", "vpy"];

if path.is_file() {
Ok(Box::new(std::iter::once(path.to_path_buf())))
} else if path.is_dir() {
ensure!(path.exists(), "Input path {:?} does not exist. Please ensure you typed it properly and it has not been moved.", path);

if path.is_dir() {
Ok(Box::new(read_in_dir(path)?))
} else {
bail!("path {:?} is not a file or directory", path)
Ok(Box::new(std::iter::once(path.to_path_buf())))
}
}

/// Returns vector of Encode args ready to be fed to encoder
pub fn parse_cli(args: CliOpts) -> anyhow::Result<Vec<EncodeArgs>> {
let input_paths = &*args.input;

let inputs: Vec<PathBuf> = input_paths
.iter()
.flat_map(|input| resolve_file_paths(input))
.flatten()
.collect();
let mut inputs = Vec::new();
for path in input_paths {
inputs.extend(resolve_file_paths(path)?);
}

let mut valid_args: Vec<EncodeArgs> = Vec::with_capacity(inputs.len());

Expand Down