Misc API Documentation

Provides API functions for miscellaneous or global operations.

This module contains functions that are not tied to a specific server instance, such as managing the global download cache for server executables. Operations are designed to be thread-safe.

bedrock_server_manager.api.misc.prune_download_cache(download_dir: str, keep_count: int | None = None, app_context: AppContext | None = None) Dict[str, str]

Prunes old downloaded server archives (.zip) in a directory.

This function removes older bedrock-server-*.zip archive files from the specified download_dir, keeping a specified number of the most recent files. It delegates the actual pruning logic to prune_old_downloads().

The operation uses a non-blocking lock (_misc_lock) to ensure thread safety; if another pruning operation is in progress, this call will be skipped, returning a “skipped” status. Triggers before_prune_download_cache and after_prune_download_cache plugin events.

Parameters:
  • download_dir (str) – The path to the directory containing the downloaded server archives.

  • keep_count (Optional[int], optional) – The number of recent archives to keep. If None, the value from the global application setting retention.downloads (defaulting to 3 if not set) is used. Defaults to None.

Returns:

A dictionary with the operation result. Possible statuses: “success”, “error”, or “skipped” (if lock not acquired). Example: {"status": "success", "message": "Download cache pruned..."}

Return type:

Dict[str, str]

Raises: