Switch to Rust 2018

This commit is contained in:
Antoine Gersant 2018-10-30 23:37:32 -07:00
parent 5de59d8687
commit 59b0dda760
15 changed files with 64 additions and 63 deletions

View file

@ -2,6 +2,7 @@
name = "polaris"
version = "0.8.0"
authors = ["Antoine Gersant <antoine.gersant@lesforges.org>"]
edition = "2018"
[features]
ui = []

View file

@ -20,18 +20,18 @@ use std::sync::{Arc, Mutex};
use typemap;
use url::percent_encoding::percent_decode;
use config;
use db::misc_settings;
use db::{ConnectionSource, DB};
use errors::*;
use index;
use lastfm;
use playlist;
use serve;
use thumbnails::*;
use user;
use utils::*;
use vfs::VFSSource;
use crate::config;
use crate::db::misc_settings;
use crate::db::{ConnectionSource, DB};
use crate::errors::*;
use crate::index;
use crate::lastfm;
use crate::playlist;
use crate::serve;
use crate::thumbnails::*;
use crate::user;
use crate::utils::*;
use crate::vfs::VFSSource;
const CURRENT_MAJOR_VERSION: i32 = 2;
const CURRENT_MINOR_VERSION: i32 = 2;

View file

@ -8,13 +8,13 @@ use std::io::Read;
use std::path;
use toml;
use db::ConnectionSource;
use db::DB;
use db::{ddns_config, misc_settings, mount_points, users};
use ddns::DDNSConfig;
use errors::*;
use user::*;
use vfs::MountPoint;
use crate::db::ConnectionSource;
use crate::db::DB;
use crate::db::{ddns_config, misc_settings, mount_points, users};
use crate::ddns::DDNSConfig;
use crate::errors::*;
use crate::user::*;
use crate::vfs::MountPoint;
#[derive(Debug, Queryable)]
pub struct MiscSettings {

View file

@ -6,7 +6,7 @@ use std::fs;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, MutexGuard};
use errors::*;
use crate::errors::*;
mod schema;
@ -85,7 +85,7 @@ impl ConnectionSource for DB {
}
pub fn _get_test_db(name: &str) -> DB {
use config;
use crate::config;
let config_path = Path::new("test/config.toml");
let config = config::parse_toml_file(&config_path).unwrap();

View file

@ -5,9 +5,9 @@ use std::io;
use std::thread;
use std::time;
use db::ddns_config;
use db::{ConnectionSource, DB};
use errors;
use crate::db::ddns_config;
use crate::db::{ConnectionSource, DB};
use crate::errors;
#[derive(Clone, Debug, Deserialize, Insertable, PartialEq, Queryable, Serialize)]
#[table_name = "ddns_config"]

View file

@ -14,14 +14,14 @@ use std::sync::{Arc, Mutex};
use std::thread;
use std::time;
use config::MiscSettings;
use crate::config::MiscSettings;
#[cfg(test)]
use db;
use db::ConnectionSource;
use db::{directories, misc_settings, songs};
use errors;
use metadata;
use vfs::{VFSSource, VFS};
use crate::db;
use crate::db::ConnectionSource;
use crate::db::{directories, misc_settings, songs};
use crate::errors;
use crate::metadata;
use crate::vfs::{VFSSource, VFS};
const INDEX_BUILDING_INSERT_BUFFER_SIZE: usize = 1000; // Insertions in each transaction
const INDEX_BUILDING_CLEAN_BUFFER_SIZE: usize = 500; // Insertions in each transaction

View file

@ -6,11 +6,11 @@ use std::collections::HashMap;
use std::io::Read;
use std::path::Path;
use db::ConnectionSource;
use errors;
use index;
use user;
use vfs::VFSSource;
use crate::db::ConnectionSource;
use crate::errors;
use crate::index;
use crate::user;
use crate::vfs::VFSSource;
const LASTFM_API_KEY: &str = "02b96c939a2b451c31dfd67add1f696e";
const LASTFM_API_SECRET: &str = "0f25a80ceef4b470b5cb97d99d4b3420";

View file

@ -59,7 +59,7 @@ use std::io::prelude::*;
use unix_daemonize::{daemonize_redirect, ChdirMode};
use core::ops::Deref;
use errors::*;
use crate::errors::*;
use getopts::Options;
use iron::prelude::*;
use mount::Mount;

View file

@ -7,9 +7,9 @@ use regex::Regex;
use std::fs;
use std::path::Path;
use errors::*;
use utils;
use utils::AudioFormat;
use crate::errors::*;
use crate::utils;
use crate::utils::AudioFormat;
#[derive(Debug, Clone, PartialEq)]
pub struct SongTags {

View file

@ -7,12 +7,12 @@ use diesel::BelongingToDsl;
use std::path::Path;
#[cfg(test)]
use db;
use db::ConnectionSource;
use db::{playlist_songs, playlists, users};
use errors::*;
use index::{self, Song};
use vfs::VFSSource;
use crate::db;
use crate::db::ConnectionSource;
use crate::db::{playlist_songs, playlists, users};
use crate::errors::*;
use crate::index::{self, Song};
use crate::vfs::VFSSource;
#[derive(Insertable)]
#[table_name = "playlists"]
@ -262,7 +262,7 @@ fn test_delete_playlist() {
#[test]
fn test_fill_playlist() {
use index;
use crate::index;
let db = db::_get_test_db("fill_playlist.sqlite");
index::update(&db).unwrap();

View file

@ -11,7 +11,7 @@ use std::fs::{self, File};
use std::io::{self, Read, Seek, SeekFrom, Write};
use std::path::Path;
use errors::{Error, ErrorKind};
use crate::errors::{Error, ErrorKind};
pub fn deliver(path: &Path, range_header: Option<&Range>) -> IronResult<Response> {
match fs::metadata(path) {

View file

@ -11,8 +11,8 @@ use std::fs::{DirBuilder, File};
use std::hash::{Hash, Hasher};
use std::path::*;
use errors::*;
use utils;
use crate::errors::*;
use crate::utils;
const THUMBNAILS_PATH: &str = "thumbnails";

View file

@ -4,9 +4,9 @@ use diesel::prelude::*;
use rand;
use ring::{digest, pbkdf2};
use db::users;
use db::ConnectionSource;
use errors::*;
use crate::db::users;
use crate::db::ConnectionSource;
use crate::errors::*;
#[derive(Debug, Insertable, Queryable)]
#[table_name = "users"]
@ -65,7 +65,7 @@ pub fn auth<T>(db: &T, username: &str, password: &str) -> Result<bool>
where
T: ConnectionSource,
{
use db::users::dsl::*;
use crate::db::users::dsl::*;
let connection = db.get_connection();
match users
.select((password_hash, password_salt))
@ -82,7 +82,7 @@ pub fn count<T>(db: &T) -> Result<i64>
where
T: ConnectionSource,
{
use db::users::dsl::*;
use crate::db::users::dsl::*;
let connection = db.get_connection();
let count = users.count().get_result(connection.deref())?;
Ok(count)
@ -92,7 +92,7 @@ pub fn is_admin<T>(db: &T, username: &str) -> Result<bool>
where
T: ConnectionSource,
{
use db::users::dsl::*;
use crate::db::users::dsl::*;
let connection = db.get_connection();
let is_admin: i32 = users
.filter(name.eq(username))
@ -105,7 +105,7 @@ pub fn lastfm_link<T>(db: &T, username: &str, lastfm_login: &str, session_key: &
where
T: ConnectionSource,
{
use db::users::dsl::*;
use crate::db::users::dsl::*;
let connection = db.get_connection();
diesel::update(users.filter(name.eq(username)))
.set((
@ -119,7 +119,7 @@ pub fn get_lastfm_session_key<T>(db: &T, username: &str) -> Result<String>
where
T: ConnectionSource,
{
use db::users::dsl::*;
use crate::db::users::dsl::*;
let connection = db.get_connection();
let token = users
.filter(name.eq(username))
@ -135,7 +135,7 @@ pub fn lastfm_unlink<T>(db: &T, username: &str) -> Result<()>
where
T: ConnectionSource,
{
use db::users::dsl::*;
use crate::db::users::dsl::*;
let connection = db.get_connection();
diesel::update(users.filter(name.eq(username)))
.set((lastfm_session_key.eq(""), lastfm_username.eq("")))

View file

@ -2,7 +2,7 @@ use app_dirs::{app_root, AppDataType, AppInfo};
use std::fs;
use std::path::{Path, PathBuf};
use errors::*;
use crate::errors::*;
#[cfg(not(target_os = "linux"))]
const APP_INFO: AppInfo = AppInfo {

View file

@ -4,9 +4,9 @@ use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;
use db::mount_points;
use db::{ConnectionSource, DB};
use errors::*;
use crate::db::mount_points;
use crate::db::{ConnectionSource, DB};
use crate::errors::*;
pub trait VFSSource {
fn get_vfs(&self) -> Result<VFS>;