From bff95f20ec3f79a356a30733145f44adc99d2f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 22 May 2019 22:03:59 -0700 Subject: [PATCH] feat(read): added has_content() --- src/content/read.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/content/read.rs b/src/content/read.rs index 4c30286..f3a6e1e 100644 --- a/src/content/read.rs +++ b/src/content/read.rs @@ -19,3 +19,11 @@ pub fn read_to_string(cache: &Path, sri: &Integrity) -> io::Result { pub fn copy(cache: &Path, sri: &Integrity, to: &Path) -> io::Result { fs::copy(content_path(&cache, &sri), to) } + +pub fn has_content(cache: &Path, sri: &Integrity) -> Option { + if content_path(&cache, &sri).exists() { + Some(sri.clone()) + } else { + None + } +}