diff --git a/src/config.rs b/src/config.rs index 2bdd95c..6bc0e60 100644 --- a/src/config.rs +++ b/src/config.rs @@ -73,7 +73,7 @@ impl Config { }; root.push(DEFAULT_CONFIG_FILE_NAME); root - }, + } }; println!("Loading config from: {}", config_path.to_string_lossy()); diff --git a/src/index.rs b/src/index.rs index 25dedea..2bb1292 100644 --- a/src/index.rs +++ b/src/index.rs @@ -106,8 +106,9 @@ impl<'db> IndexBuilder<'db> { artist, album) VALUES (?, ?, ?, ?, ?, ?)") .unwrap(), insert_song: - db.prepare("INSERT OR REPLACE INTO songs (path, parent, disc_number, track_number, title, year, \ - album_artist, artist, album, artwork) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") + db.prepare("INSERT OR REPLACE INTO songs (path, parent, disc_number, track_number, \ + title, year, album_artist, artist, album, artwork) VALUES (?, ?, ?, ?, \ + ?, ?, ?, ?, ?, ?)") .unwrap(), } } @@ -183,9 +184,7 @@ impl<'db> Drop for IndexBuilder<'db> { } impl Index { - pub fn new(vfs: Arc, - config: &IndexConfig) - -> Result { + pub fn new(vfs: Arc, config: &IndexConfig) -> Result { let mut path = try!(utils::get_cache_root()); path.push(INDEX_FILE_NAME); @@ -246,14 +245,14 @@ impl Index { , disc_number INTEGER , track_number INTEGER , title TEXT - , artist TEXT - , \ - album_artist TEXT + \ + , artist TEXT + , album_artist TEXT , year INTEGER , album TEXT - , artwork TEXT - , \ - UNIQUE(path) + \ + , artwork TEXT + , UNIQUE(path) ); ") @@ -530,8 +529,9 @@ impl Index { let db = self.connect(); let path_string = real_path.to_string_lossy(); let mut select = - db.prepare("SELECT path, disc_number, track_number, title, year, album_artist, artist, album, \ - artwork FROM songs WHERE parent = ? ORDER BY path COLLATE NOCASE ASC") + db.prepare("SELECT path, disc_number, track_number, title, year, album_artist, \ + artist, album, artwork FROM songs WHERE parent = ? ORDER BY path \ + COLLATE NOCASE ASC") .unwrap(); select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap(); self.select_songs(&mut select).into_iter().map(|s| CollectionFile::Song(s)).collect() @@ -571,8 +571,9 @@ impl Index { let real_path = try!(self.vfs.virtual_to_real(virtual_path)); let path_string = real_path.to_string_lossy().into_owned() + "%"; let mut select = - db.prepare("SELECT path, disc_number, track_number, title, year, album_artist, artist, album, \ - artwork FROM songs WHERE path LIKE ? ORDER BY path COLLATE NOCASE ASC") + db.prepare("SELECT path, disc_number, track_number, title, year, album_artist, \ + artist, album, artwork FROM songs WHERE path LIKE ? ORDER BY path \ + COLLATE NOCASE ASC") .unwrap(); select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap(); Ok(self.select_songs(&mut select)) diff --git a/src/main.rs b/src/main.rs index 520db64..c4191a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,8 +70,7 @@ fn main() { // Init index println!("Starting up index"); - let index = Arc::new(index::Index::new(vfs.clone(), &config.index) - .unwrap()); + let index = Arc::new(index::Index::new(vfs.clone(), &config.index).unwrap()); let index_ref = index.clone(); std::thread::spawn(move || index_ref.run()); diff --git a/src/thumbnails.rs b/src/thumbnails.rs index 8fc89de..0a9a3f3 100644 --- a/src/thumbnails.rs +++ b/src/thumbnails.rs @@ -24,7 +24,7 @@ fn hash(path: &Path, dimension: u32) -> u64 { pub fn get_thumbnail(real_path: &Path, max_dimension: u32) -> Result { - let mut out_path = try!(utils::get_cache_root()); + let mut out_path = try!(utils::get_cache_root()); out_path.push(THUMBNAILS_PATH); let mut dir_builder = DirBuilder::new(); diff --git a/src/utils.rs b/src/utils.rs index 7e81b37..24a9cde 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,24 +5,24 @@ use std::fs; use error::PError; pub fn get_config_root() -> Result { - if let Ok(mut root) = data_root(AppDataType::SharedConfig){ + if let Ok(mut root) = data_root(AppDataType::SharedConfig) { root.push("Polaris"); return match fs::create_dir_all(&root) { Ok(()) => Ok(root), Err(_) => Err(PError::CacheDirectoryError), - } - } + }; + } Err(PError::ConfigDirectoryError) } pub fn get_cache_root() -> Result { - if let Ok(mut root) = data_root(AppDataType::SharedData){ + if let Ok(mut root) = data_root(AppDataType::SharedData) { root.push("Polaris"); return match fs::create_dir_all(&root) { Ok(()) => Ok(root), Err(_) => Err(PError::CacheDirectoryError), - } - } + }; + } Err(PError::CacheDirectoryError) } @@ -56,8 +56,10 @@ pub fn get_audio_format(path: &Path) -> Option { #[test] fn test_get_audio_format() { - assert_eq!(get_audio_format(Path::new("animals/🐷/my🐖file.jpg")), None); - assert_eq!(get_audio_format(Path::new("animals/🐷/my🐖file.flac")), Some(AudioFormat::FLAC)); + assert_eq!(get_audio_format(Path::new("animals/🐷/my🐖file.jpg")), + None); + assert_eq!(get_audio_format(Path::new("animals/🐷/my🐖file.flac")), + Some(AudioFormat::FLAC)); } pub fn is_song(path: &Path) -> bool {