Skip to content

Commit

Permalink
sample & snappy: adjust download_file calls to use PathBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Aug 31, 2023
1 parent d07189a commit b9408cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/cmd/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
Some(uri) => {
if Url::parse(&uri).is_ok() && uri.starts_with("http") {
// its a remote file, download it first
let temp_download_path = temp_download.path().to_str().unwrap().to_string();

let future = util::download_file(
&uri,
&temp_download_path,
temp_download.path().to_path_buf(),
false,
args.flag_user_agent,
args.flag_timeout,
None,
);
tokio::runtime::Runtime::new()?.block_on(future)?;
// safety: temp_download is a NamedTempFile, so we know it can be converted to a
// string
let temp_download_path = temp_download.path().to_str().unwrap().to_string();
Some(temp_download_path)
} else {
// its a local file
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/snappy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
Some(uri) => {
let path = if Url::parse(uri).is_ok() && uri.starts_with("http") {
// its a remote file, download it first
let temp_download_path = temp_download.path().to_str().unwrap().to_string();

let future = util::download_file(
uri,
&temp_download_path,
temp_download.path().to_path_buf(),
args.flag_progressbar && !args.cmd_check && !args.flag_quiet,
args.flag_user_agent,
Some(args.flag_timeout),
Expand All @@ -121,6 +119,8 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
},
);
tokio::runtime::Runtime::new()?.block_on(future)?;
// safety: temp_download is a NamedTempFile, so we know that it can be converted
let temp_download_path = temp_download.path().to_str().unwrap().to_string();
temp_download_path
} else {
// its a local file
Expand Down

0 comments on commit b9408cb

Please sign in to comment.