MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / remove_cache

Method remove_cache

kms/src/main_service.rs:196–219  ·  view source on GitHub ↗
(&self, parent_dir: &Path, sub_dir: &str)

Source from the content-addressed store, hash-verified

194 }
195
196 fn remove_cache(&self, parent_dir: &Path, sub_dir: &str) -> Result<()> {
197 if sub_dir.is_empty() {
198 return Ok(());
199 }
200
201 if sub_dir == "all" {
202 fs::remove_dir_all(parent_dir)?;
203 return Ok(());
204 }
205
206 if !sub_dir.chars().all(|c| c.is_ascii_hexdigit()) {
207 bail!("Invalid cache key");
208 }
209
210 let path = parent_dir.join(sub_dir);
211
212 if path.is_dir() {
213 fs::remove_dir_all(path)?;
214 } else if path.is_file() {
215 fs::remove_file(path)?;
216 }
217
218 Ok(())
219 }
220
221 fn ensure_admin(&self, token: &str) -> Result<()> {
222 let token_hash = sha2::Sha256::new_with_prefix(token).finalize();

Callers 1

clear_image_cacheMethod · 0.80

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected