mirror of https://github.com/zkat/cacache-rs.git
feat(rm): added external rm api
This commit is contained in:
parent
f3b6abf45c
commit
346cf5fb23
|
|
@ -1,6 +1,7 @@
|
|||
mod content;
|
||||
pub mod get;
|
||||
pub mod put;
|
||||
pub mod rm;
|
||||
mod index;
|
||||
mod errors;
|
||||
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
Loading…
Reference in New Issue