feat(read): added has_content()

This commit is contained in:
Kat Marchán 2019-05-22 22:03:59 -07:00
parent 70cf52e136
commit bff95f20ec
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
1 changed files with 8 additions and 0 deletions

View File

@ -19,3 +19,11 @@ pub fn read_to_string(cache: &Path, sri: &Integrity) -> io::Result<String> {
pub fn copy(cache: &Path, sri: &Integrity, to: &Path) -> io::Result<u64> {
fs::copy(content_path(&cache, &sri), to)
}
pub fn has_content(cache: &Path, sri: &Integrity) -> Option<Integrity> {
if content_path(&cache, &sri).exists() {
Some(sri.clone())
} else {
None
}
}