summaryrefslogtreecommitdiffstats
path: root/src/fetch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fetch.rs')
-rw-r--r--src/fetch.rs4
1 files changed, 0 insertions, 4 deletions
diff --git a/src/fetch.rs b/src/fetch.rs
index c802339..1d06051 100644
--- a/src/fetch.rs
+++ b/src/fetch.rs
@@ -17,8 +17,6 @@ impl Read for Body {
}
}
-/// Open a URL for streaming. Never buffers the whole body: sources are hashed
-/// while they are written into the cache (ยง5.3).
pub fn open(url: &str) -> Result<(Body, Option<u64>)> {
if let Some(path) = url.strip_prefix("file://") {
let p = path.trim_start_matches('/');
@@ -40,7 +38,6 @@ pub fn open(url: &str) -> Result<(Body, Option<u64>)> {
Err(Error::invalid(format!("unsupported url scheme: {url}")))
}
-/// Fetch `url` into `dest`, returning `(sha256, size)`.
pub fn fetch_to(url: &str, dest: &std::path::Path) -> Result<(String, u64)> {
if let Some(parent) = dest.parent() {
std::fs::create_dir_all(parent)?;
@@ -53,7 +50,6 @@ pub fn fetch_to(url: &str, dest: &std::path::Path) -> Result<(String, u64)> {
let (digest, size) = crate::hash::digest_reader(std::io::BufReader::new(body), Some(&mut file))
.map_err(|e| Error::Http(format!("{url}: {e}")))?;
file.flush()?;
- // Rename into place: a half-written cache entry must never be visible.
std::fs::rename(&tmp, dest)?;
Ok((digest, size))
}