mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
main: Fix cache setup
This commit is contained in:
parent
541114e2b4
commit
b8e4febb8e
1 changed files with 5 additions and 9 deletions
14
src/main.rs
14
src/main.rs
|
@ -185,18 +185,19 @@ struct Main {
|
||||||
impl Main {
|
impl Main {
|
||||||
fn new(handle: Handle,
|
fn new(handle: Handle,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
cache: Option<Cache>,
|
||||||
backend: fn(Option<String>) -> Box<Sink>,
|
backend: fn(Option<String>) -> Box<Sink>,
|
||||||
device: Option<String>,
|
device: Option<String>,
|
||||||
mixer: fn() -> Box<Mixer>) -> Main
|
mixer: fn() -> Box<Mixer>) -> Main
|
||||||
{
|
{
|
||||||
Main {
|
Main {
|
||||||
handle: handle.clone(),
|
handle: handle.clone(),
|
||||||
|
cache: cache,
|
||||||
config: config,
|
config: config,
|
||||||
backend: backend,
|
backend: backend,
|
||||||
device: device,
|
device: device,
|
||||||
mixer: mixer,
|
mixer: mixer,
|
||||||
|
|
||||||
cache: None,
|
|
||||||
connect: Box::new(futures::future::empty()),
|
connect: Box::new(futures::future::empty()),
|
||||||
discovery: None,
|
discovery: None,
|
||||||
spirc: None,
|
spirc: None,
|
||||||
|
@ -215,6 +216,7 @@ impl Main {
|
||||||
fn credentials(&mut self, credentials: Credentials) {
|
fn credentials(&mut self, credentials: Credentials) {
|
||||||
let config = self.config.clone();
|
let config = self.config.clone();
|
||||||
let handle = self.handle.clone();
|
let handle = self.handle.clone();
|
||||||
|
|
||||||
let connection = Session::connect(config, credentials, self.cache.clone(), handle);
|
let connection = Session::connect(config, credentials, self.cache.clone(), handle);
|
||||||
|
|
||||||
self.connect = connection;
|
self.connect = connection;
|
||||||
|
@ -224,10 +226,6 @@ impl Main {
|
||||||
self.handle.spawn(task);
|
self.handle.spawn(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cache(&mut self, cache: Cache) {
|
|
||||||
self.cache = Some(cache);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Future for Main {
|
impl Future for Main {
|
||||||
|
@ -302,16 +300,14 @@ fn main() {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
let Setup { backend, config, device, cache, enable_discovery, credentials, mixer } = setup(&args);
|
let Setup { backend, config, device, cache, enable_discovery, credentials, mixer } = setup(&args);
|
||||||
|
|
||||||
let mut task = Main::new(handle, config.clone(), backend, device, mixer);
|
let mut task = Main::new(handle, config.clone(), cache, backend, device, mixer);
|
||||||
if enable_discovery {
|
if enable_discovery {
|
||||||
task.discovery();
|
task.discovery();
|
||||||
}
|
}
|
||||||
if let Some(credentials) = credentials {
|
if let Some(credentials) = credentials {
|
||||||
task.credentials(credentials);
|
task.credentials(credentials);
|
||||||
}
|
}
|
||||||
if let Some(cache) = cache {
|
|
||||||
task.cache(cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
core.run(task).unwrap()
|
core.run(task).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue