MCPcopy Create free account
hub / github.com/evilsocket/cake / delete_model

Function delete_model

cake-core/src/utils/models.rs:130–152  ·  view source on GitHub ↗

Delete a cached model from disk. For HuggingFace cache models, removes the entire `models--org--name/` directory (including all snapshots and blobs). For cluster cache models, removes the model directory. Refuses to delete local models.

(model: &LocalModel)

Source from the content-addressed store, hash-verified

128/// (including all snapshots and blobs). For cluster cache models, removes the model
129/// directory. Refuses to delete local models.
130pub fn delete_model(model: &LocalModel) -> Result<()> {
131 match model.source {
132 ModelSource::HuggingFaceCache => {
133 // model.path is .../snapshots/{hash}/ — go up to models--org--name/
134 let hf_model_dir = model
135 .path
136 .parent() // snapshots/
137 .and_then(|p| p.parent()) // models--org--name/
138 .ok_or_else(|| anyhow::anyhow!("unexpected HF cache structure for {}", model.path.display()))?;
139 std::fs::remove_dir_all(hf_model_dir)?;
140 }
141 ModelSource::ClusterCache { .. } => {
142 std::fs::remove_dir_all(&model.path)?;
143 }
144 ModelSource::Local => {
145 anyhow::bail!(
146 "refusing to delete local model '{}' — use rm -rf manually",
147 model.name
148 );
149 }
150 }
151 Ok(())
152}
153
154/// Check a single directory and return its model status, or None if it's not a model dir.
155fn check_model_dir(dir: &Path) -> Option<(ModelStatus, u64)> {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected