Removed redundant derefs
This commit is contained in:
parent
50421e91d6
commit
f9ebb432b2
4 changed files with 20 additions and 23 deletions
|
@ -1,5 +1,4 @@
|
|||
use anyhow::*;
|
||||
use core::ops::Deref;
|
||||
use diesel::prelude::*;
|
||||
use log::{error, info};
|
||||
use reqwest;
|
||||
|
@ -28,7 +27,7 @@ impl DDNSConfigSource for DB {
|
|||
let connection = self.connect()?;
|
||||
Ok(ddns_config
|
||||
.select((host, username, password))
|
||||
.get_result(connection.deref())?)
|
||||
.get_result(&connection)?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
28
src/index.rs
28
src/index.rs
|
@ -371,7 +371,7 @@ fn clean(db: &DB) -> Result<()> {
|
|||
let connection = db.connect()?;
|
||||
for chunk in missing_songs[..].chunks(INDEX_BUILDING_CLEAN_BUFFER_SIZE) {
|
||||
diesel::delete(songs::table.filter(songs::path.eq_any(chunk)))
|
||||
.execute(connection.deref())?;
|
||||
.execute(&connection)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ fn clean(db: &DB) -> Result<()> {
|
|||
let connection = db.connect()?;
|
||||
all_directories = directories::table
|
||||
.select(directories::path)
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
}
|
||||
|
||||
let missing_directories = all_directories
|
||||
|
@ -397,7 +397,7 @@ fn clean(db: &DB) -> Result<()> {
|
|||
let connection = db.connect()?;
|
||||
for chunk in missing_directories[..].chunks(INDEX_BUILDING_CLEAN_BUFFER_SIZE) {
|
||||
diesel::delete(directories::table.filter(directories::path.eq_any(chunk)))
|
||||
.execute(connection.deref())?;
|
||||
.execute(&connection)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ where
|
|||
// Browse top-level
|
||||
let real_directories: Vec<Directory> = directories::table
|
||||
.filter(directories::parent.is_null())
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
let virtual_directories = real_directories
|
||||
.into_iter()
|
||||
.filter_map(|s| virtualize_directory(&vfs, s));
|
||||
|
@ -546,7 +546,7 @@ where
|
|||
let real_directories: Vec<Directory> = directories::table
|
||||
.filter(directories::parent.eq(&real_path_string))
|
||||
.order(sql::<sql_types::Bool>("path COLLATE NOCASE ASC"))
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
let virtual_directories = real_directories
|
||||
.into_iter()
|
||||
.filter_map(|s| virtualize_directory(&vfs, s));
|
||||
|
@ -555,7 +555,7 @@ where
|
|||
let real_songs: Vec<Song> = songs::table
|
||||
.filter(songs::parent.eq(&real_path_string))
|
||||
.order(sql::<sql_types::Bool>("path COLLATE NOCASE ASC"))
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
let virtual_songs = real_songs
|
||||
.into_iter()
|
||||
.filter_map(|s| virtualize_song(&vfs, s));
|
||||
|
@ -579,9 +579,9 @@ where
|
|||
songs
|
||||
.filter(path.like(&like_path))
|
||||
.order(path)
|
||||
.load(connection.deref())?
|
||||
.load(&connection)?
|
||||
} else {
|
||||
songs.order(path).load(connection.deref())?
|
||||
songs.order(path).load(&connection)?
|
||||
};
|
||||
|
||||
let virtual_songs = real_songs
|
||||
|
@ -598,7 +598,7 @@ pub fn get_random_albums(db: &DB, count: i64) -> Result<Vec<Directory>> {
|
|||
.filter(album.is_not_null())
|
||||
.limit(count)
|
||||
.order(random)
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
let virtual_directories = real_directories
|
||||
.into_iter()
|
||||
.filter_map(|s| virtualize_directory(&vfs, s));
|
||||
|
@ -613,7 +613,7 @@ pub fn get_recent_albums(db: &DB, count: i64) -> Result<Vec<Directory>> {
|
|||
.filter(album.is_not_null())
|
||||
.order(date_added.desc())
|
||||
.limit(count)
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
let virtual_directories = real_directories
|
||||
.into_iter()
|
||||
.filter_map(|s| virtualize_directory(&vfs, s));
|
||||
|
@ -632,7 +632,7 @@ pub fn search(db: &DB, query: &str) -> Result<Vec<CollectionFile>> {
|
|||
let real_directories: Vec<Directory> = directories
|
||||
.filter(path.like(&like_test))
|
||||
.filter(parent.not_like(&like_test))
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
|
||||
let virtual_directories = real_directories
|
||||
.into_iter()
|
||||
|
@ -653,7 +653,7 @@ pub fn search(db: &DB, query: &str) -> Result<Vec<CollectionFile>> {
|
|||
.or(album_artist.like(&like_test)),
|
||||
)
|
||||
.filter(parent.not_like(&like_test))
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
|
||||
let virtual_songs = real_songs
|
||||
.into_iter()
|
||||
|
@ -674,7 +674,7 @@ pub fn get_song(db: &DB, virtual_path: &Path) -> Result<Song> {
|
|||
use self::songs::dsl::*;
|
||||
let real_song: Song = songs
|
||||
.filter(path.eq(real_path_string))
|
||||
.get_result(connection.deref())?;
|
||||
.get_result(&connection)?;
|
||||
|
||||
match virtualize_song(&vfs, real_song) {
|
||||
Some(s) => Ok(s),
|
||||
|
@ -715,7 +715,7 @@ fn test_metadata() {
|
|||
let connection = db.connect().unwrap();
|
||||
let songs: Vec<Song> = songs::table
|
||||
.filter(songs::title.eq("シャーベット (Sherbet)"))
|
||||
.load(connection.deref())
|
||||
.load(&connection)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(songs.len(), 1);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use anyhow::*;
|
||||
use core::clone::Clone;
|
||||
use core::ops::Deref;
|
||||
use diesel;
|
||||
use diesel::prelude::*;
|
||||
use diesel::sql_types;
|
||||
|
@ -57,14 +56,14 @@ pub fn list_playlists(owner: &str, db: &DB) -> Result<Vec<String>> {
|
|||
user = users
|
||||
.filter(name.eq(owner))
|
||||
.select((id,))
|
||||
.first(connection.deref())?;
|
||||
.first(&connection)?;
|
||||
}
|
||||
|
||||
{
|
||||
use self::playlists::dsl::*;
|
||||
let found_playlists: Vec<String> = Playlist::belonging_to(&user)
|
||||
.select(name)
|
||||
.load(connection.deref())?;
|
||||
.load(&connection)?;
|
||||
Ok(found_playlists)
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +128,7 @@ pub fn save_playlist(playlist_name: &str, owner: &str, content: &[String], db: &
|
|||
connection.transaction::<_, diesel::result::Error, _>(|| {
|
||||
// Delete old content (if any)
|
||||
let old_songs = PlaylistSong::belonging_to(&playlist);
|
||||
diesel::delete(old_songs).execute(connection.deref())?;
|
||||
diesel::delete(old_songs).execute(&connection)?;
|
||||
|
||||
// Insert content
|
||||
diesel::insert_into(playlist_songs::table)
|
||||
|
@ -207,7 +206,7 @@ pub fn delete_playlist(playlist_name: &str, owner: &str, db: &DB) -> Result<()>
|
|||
{
|
||||
use self::playlists::dsl::*;
|
||||
let q = Playlist::belonging_to(&user).filter(name.eq(playlist_name));
|
||||
diesel::delete(q).execute(connection.deref())?;
|
||||
diesel::delete(q).execute(&connection)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use anyhow::*;
|
||||
use core::ops::Deref;
|
||||
use diesel::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
@ -20,7 +19,7 @@ impl VFSSource for DB {
|
|||
let connection = self.connect()?;
|
||||
let points: Vec<MountPoint> = mount_points
|
||||
.select((source, name))
|
||||
.get_results(connection.deref())?;
|
||||
.get_results(&connection)?;
|
||||
for point in points {
|
||||
vfs.mount(&Path::new(&point.source), &point.name)?;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue