diff --git a/src/config.rs b/src/config.rs index 6092185..6241471 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,7 +5,7 @@ use std::path; use toml; use errors::*; -use db::NewMountPoint; +use db::MountPoint; use ddns::DDNSConfig; #[derive(Deserialize)] @@ -18,7 +18,7 @@ pub struct User { pub struct UserConfig { pub album_art_pattern: Option, pub reindex_every_n_seconds: Option, - pub mount_dirs: Option>, + pub mount_dirs: Option>, pub users: Option>, pub ydns: Option, } diff --git a/src/db/mod.rs b/src/db/mod.rs index 68015ae..b75c899 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -130,12 +130,15 @@ impl DB { } fn get_vfs(&self) -> Result { + use self::mount_points::dsl::*; let mut vfs = Vfs::new(); let connection = self.connection.lock().unwrap(); let connection = connection.deref(); - let mount_points: Vec = mount_points::table.get_results(connection)?; - for mount_point in mount_points { - vfs.mount(&Path::new(&mount_point.real_path), &mount_point.name)?; + let points: Vec = mount_points + .select((source, name)) + .get_results(connection)?; + for point in points { + vfs.mount(&Path::new(&point.source), &point.name)?; } Ok(vfs) } diff --git a/src/db/models.rs b/src/db/models.rs index e7de97d..b3afe57 100644 --- a/src/db/models.rs +++ b/src/db/models.rs @@ -99,18 +99,11 @@ impl NewUser { // VFS -#[derive(Debug, Queryable)] -pub struct MountPoint { - id: i32, - pub real_path: String, - pub name: String, -} - -#[derive(Deserialize, Insertable)] +#[derive(Debug, Deserialize, Insertable, Queryable)] #[table_name="mount_points"] -pub struct NewMountPoint { - pub name: String, +pub struct MountPoint { pub source: String, + pub name: String, }