diff --git a/src/lib.rs b/src/lib.rs index 6f86cc4..a9ca418 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -128,12 +128,17 @@ pub fn fetch(params: FetchParams, builder: impl DictionaryBuilder) -> Result<(), // copy(&source_path, &source_path_for_build)?; let tmp_path = Path::new(&build_dir).join(params.file_name.to_owned() + ".download"); + if let Some(path) = params.download_url.strip_prefix("file://") { + std::fs::copy(path, &tmp_path)?; + } + else { // Download a tarball let resp = ureq::get(params.download_url).call()?; let mut dest = File::create(&tmp_path)?; io::copy(&mut resp.into_reader(), &mut dest)?; dest.flush()?; + } rename(tmp_path, source_path_for_build).expect("Failed to rename temporary file"); @@ -153,7 +158,6 @@ pub fn fetch(params: FetchParams, builder: impl DictionaryBuilder) -> Result<(), archive.unpack(&tmp_extract_path)?; rename(tmp_extracted_path, &input_dir).expect("Failed to rename archive directory"); let _ = std::fs::remove_dir_all(&tmp_extract_path); - drop(dest); let _ = std::fs::remove_file(source_path_for_build); }