MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / delete_mod

Method delete_mod

mserver/MasterService/src/mods.rs:407–435  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).

Callers 1

delete_modFunction · 0.45

Calls 2

is_safe_segmentFunction · 0.85
store_pathMethod · 0.80

Tested by

no test coverage detected