Skip to content

Commit

Permalink
Expose librespots support for limiting the cache size via a cli flag and
Browse files Browse the repository at this point in the history
a config entry

Fixes Spotifyd#1066
  • Loading branch information
weiznich committed Jun 28, 2022
1 parent ae6dac7 commit 7cd64ff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ pub struct SharedConfigValues {
#[structopt(long, parse(from_os_str), short, value_name = "string")]
cache_path: Option<PathBuf>,

/// The maximal cache size in bytes
#[structopt(long)]
max_cache_size: Option<u64>,

/// Disable the use of audio cache
#[structopt(long)]
#[serde(default)]
Expand Down Expand Up @@ -580,6 +584,7 @@ pub(crate) struct SpotifydConfig {
pub(crate) fn get_internal_config(config: CliConfig) -> SpotifydConfig {
let audio_cache = !config.shared_config.no_audio_cache;

let size_limit = config.shared_config.max_cache_size;
let cache = config
.shared_config
.cache_path
Expand All @@ -590,7 +595,7 @@ pub(crate) fn get_internal_config(config: CliConfig) -> SpotifydConfig {
Cache::new(
Some(path.clone()),
if audio_cache { Some(path) } else { None },
None,
size_limit,
)
.ok()
});
Expand Down

0 comments on commit 7cd64ff

Please sign in to comment.