feat(rm): added external rm api

This commit is contained in:
Kat Marchán 2019-06-05 13:41:09 +02:00
parent f3b6abf45c
commit 346cf5fb23
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 26 additions and 0 deletions

View File

@ -1,6 +1,7 @@
mod content;
pub mod get;
pub mod put;
pub mod rm;
mod index;
mod errors;

25
src/rm.rs Normal file
View File

@ -0,0 +1,25 @@
use std::fs;
use std::path::Path;
use ssri::Integrity;
use crate::content::rm;
use crate::errors::Error;
use crate::index;
pub fn entry(cache: &Path, key: &str) -> Result<(), Error> {
index::delete(&cache, &key)
}
pub fn content(cache: &Path, sri: &Integrity) -> Result<(), Error> {
rm::rm(&cache, &sri)
}
pub fn all(cache: &Path) -> Result<(), Error> {
for entry in cache.read_dir()? {
if let Ok(entry) = entry {
fs::remove_dir_all(entry.path())?;
}
}
Ok(())
}