Added some quick'n'dirty cache invalidation to "wasmer publish"

This commit is contained in:
Michael-F-Bryan
2023-06-16 17:17:24 +08:00
parent 0c8220ce22
commit aecb4282a6
2 changed files with 42 additions and 1 deletions

View File

@ -52,6 +52,20 @@ impl WapmSource {
}
}
/// Clean the local cache.
///
/// This is a workaround used primarily when publishing and will probably
/// be removed in the future.
pub fn invalidate_local_cache(wasmer_dir: impl AsRef<Path>) -> Result<(), Error> {
let cache_dir = WapmSource::default_cache_dir(wasmer_dir);
std::fs::remove_dir_all(&cache_dir).with_context(|| {
format!("Unable to delete the \"{}\" directory", cache_dir.display())
})?;
Ok(())
}
async fn lookup_package(&self, package_name: &str) -> Result<WapmWebQuery, Error> {
if let Some(cache) = &self.cache {
match cache.lookup_cached_query(package_name) {