Delete a mod from the store: its `mod.json` and its artifact. Returns `true` if the mod existed (its `mod.json` was present). Rejects unsafe ids.
(&self, mod_id: &str)
| 405 | let path = self.store_path(Self::current_path(mod_id)); |
| 406 | match self.store.get(&path).await { |
| 407 | Ok(result) => { |
| 408 | let update = UpdateVersion { |
| 409 | e_tag: result.meta.e_tag.clone(), |
| 410 | version: result.meta.version.clone(), |
| 411 | }; |
| 412 | let current: CurrentRevision = serde_json::from_slice(&result.bytes().await?) |
| 413 | .with_context(|| format!("parsing current revision for {mod_id}"))?; |
| 414 | Ok(Some(CurrentState { |
| 415 | revision: current.package_revision, |
| 416 | update: Some(update), |
| 417 | })) |
| 418 | } |
| 419 | Err(object_store::Error::NotFound { .. }) => { |
| 420 | match self |
| 421 | .store |
| 422 | .head(&self.store_path(Self::metadata_path(mod_id))) |
| 423 | .await |
| 424 | { |
| 425 | Ok(_) => Ok(Some(CurrentState { |
| 426 | revision: 1, |
| 427 | update: None, |
| 428 | })), |
| 429 | Err(object_store::Error::NotFound { .. }) => Ok(None), |
| 430 | Err(error) => Err(error.into()), |
| 431 | } |
| 432 | } |
| 433 | Err(error) => Err(error.into()), |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /// Write a catalog entry's `mod.json` (used by dev seeding; writes no artifact, so the |
| 438 | /// seeded entry carries a synthetic `size_bytes` and isn't downloadable). |
no test coverage detected