mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-03 09:49:31 +02:00
Add disable credential cache flag
As mentioned in https://github.com/librespot-org/librespot/discussions/870, this allows someone who would otherwise like to take advantage of audio file and volume caching to disable credential caching.
This commit is contained in:
parent
b4784ebf9c
commit
52bd212e43
2 changed files with 32 additions and 14 deletions
|
@ -238,29 +238,38 @@ pub struct RemoveFileError(());
|
|||
|
||||
impl Cache {
|
||||
pub fn new<P: AsRef<Path>>(
|
||||
system_location: Option<P>,
|
||||
audio_location: Option<P>,
|
||||
credentials: Option<P>,
|
||||
volume: Option<P>,
|
||||
audio: Option<P>,
|
||||
size_limit: Option<u64>,
|
||||
) -> io::Result<Self> {
|
||||
if let Some(location) = &system_location {
|
||||
let mut size_limiter = None;
|
||||
|
||||
if let Some(location) = &credentials {
|
||||
fs::create_dir_all(location)?;
|
||||
}
|
||||
|
||||
let mut size_limiter = None;
|
||||
let credentials_location = credentials
|
||||
.as_ref()
|
||||
.map(|p| p.as_ref().join("credentials.json"));
|
||||
|
||||
if let Some(location) = &audio_location {
|
||||
if let Some(location) = &volume {
|
||||
fs::create_dir_all(location)?;
|
||||
}
|
||||
|
||||
let volume_location = volume.as_ref().map(|p| p.as_ref().join("volume"));
|
||||
|
||||
if let Some(location) = &audio {
|
||||
fs::create_dir_all(location)?;
|
||||
|
||||
if let Some(limit) = size_limit {
|
||||
let limiter = FsSizeLimiter::new(location.as_ref(), limit);
|
||||
|
||||
size_limiter = Some(Arc::new(limiter));
|
||||
}
|
||||
}
|
||||
|
||||
let audio_location = audio_location.map(|p| p.as_ref().to_owned());
|
||||
let volume_location = system_location.as_ref().map(|p| p.as_ref().join("volume"));
|
||||
let credentials_location = system_location
|
||||
.as_ref()
|
||||
.map(|p| p.as_ref().join("credentials.json"));
|
||||
let audio_location = audio.map(|p| p.as_ref().to_owned());
|
||||
|
||||
let cache = Cache {
|
||||
credentials_location,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue