avoid compiler warnings
This commit is contained in:
parent
34f956bc25
commit
9f49fe1d5d
|
@ -2,7 +2,6 @@ use failure::*;
|
|||
use std::collections::HashMap;
|
||||
use serde_json::{json, Value};
|
||||
use url::form_urlencoded;
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
|
47
src/api2.rs
47
src/api2.rs
|
@ -1,8 +1,8 @@
|
|||
use failure::*;
|
||||
//use failure::*;
|
||||
|
||||
use crate::api::schema::*;
|
||||
use crate::api::router::*;
|
||||
use serde_json::{json, Value};
|
||||
use serde_json::{json};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod config;
|
||||
|
@ -29,54 +29,11 @@ lazy_static! {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn test_sync_api_handler(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
println!("This is a test {}", param);
|
||||
|
||||
// let force: Option<bool> = Some(false);
|
||||
|
||||
//if let Some(force) = param.force {
|
||||
//}
|
||||
|
||||
let _force = param["force"].as_bool()
|
||||
.ok_or_else(|| format_err!("missing parameter 'force'"))?;
|
||||
|
||||
if let Some(_force) = param["force"].as_bool() {
|
||||
}
|
||||
|
||||
Ok(json!(null))
|
||||
}
|
||||
|
||||
pub fn router() -> Router {
|
||||
|
||||
let route4 = Router::new()
|
||||
.get(ApiMethod::new(
|
||||
|param, _info, _rpcenv| {
|
||||
println!("This is a clousure handler: {}", param);
|
||||
|
||||
Ok(json!(null))
|
||||
},
|
||||
ObjectSchema::new("Another Endpoint."))
|
||||
.returns(Schema::Null));
|
||||
|
||||
|
||||
let nodeinfo = Router::new()
|
||||
.get(ApiMethod::new(
|
||||
test_sync_api_handler,
|
||||
ObjectSchema::new("This is a simple test.")
|
||||
.optional("force", BooleanSchema::new("Test for boolean options")))
|
||||
)
|
||||
.subdir("subdir3", route4);
|
||||
|
||||
let nodes = Router::new()
|
||||
.subdir("localhost", node::router());
|
||||
|
||||
|
||||
let route = Router::new()
|
||||
.get(ApiMethod::new(
|
||||
|_,_,_| Ok(json!([
|
||||
|
|
|
@ -20,7 +20,7 @@ fn authenticate_user(username: &str, password: &str) -> Result<(), Error> {
|
|||
fn create_ticket(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let username = tools::required_string_param(¶m, "username")?;
|
||||
|
|
|
@ -68,7 +68,7 @@ fn get_backup_list(
|
|||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let config = datastore::config()?;
|
||||
//let config = datastore::config()?;
|
||||
|
||||
let store = param["store"].as_str().unwrap();
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::api2::*;
|
|||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use openssl::sha;
|
||||
use regex::Regex;
|
||||
|
@ -61,7 +60,7 @@ fn update_dns(
|
|||
static ref MUTEX: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
|
||||
}
|
||||
|
||||
let guard = MUTEX.lock();
|
||||
let _guard = MUTEX.lock();
|
||||
|
||||
let search = tools::required_string_param(¶m, "search")?;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use failure::*;
|
||||
|
||||
use crate::tools;
|
||||
//use crate::tools;
|
||||
use crate::api::schema::*;
|
||||
use crate::api::router::*;
|
||||
use serde_json::{json, Value};
|
||||
|
|
|
@ -6,8 +6,6 @@ use crate::api::router::*;
|
|||
use serde_json::{json, Value};
|
||||
|
||||
use std::sync::Arc;
|
||||
use lazy_static::lazy_static;
|
||||
use crate::tools::common_regex;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
static SERVICE_NAME_LIST: [&str; 6] = [
|
||||
|
@ -91,9 +89,9 @@ fn json_service_state(service: &str, status: Value) -> Value {
|
|||
|
||||
|
||||
fn list_services(
|
||||
param: Value,
|
||||
_param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let mut list = vec![];
|
||||
|
@ -116,7 +114,7 @@ fn list_services(
|
|||
fn get_service_state(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let service = tools::required_string_param(¶m, "service")?;
|
||||
|
@ -161,7 +159,7 @@ fn run_service_command(service: &str, cmd: &str) -> Result<Value, Error> {
|
|||
fn start_service(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let service = tools::required_string_param(¶m, "service")?;
|
||||
|
@ -174,7 +172,7 @@ fn start_service(
|
|||
fn stop_service(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let service = tools::required_string_param(¶m, "service")?;
|
||||
|
@ -187,7 +185,7 @@ fn stop_service(
|
|||
fn restart_service(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let service = tools::required_string_param(¶m, "service")?;
|
||||
|
@ -200,7 +198,7 @@ fn restart_service(
|
|||
fn reload_service(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let service = tools::required_string_param(¶m, "service")?;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use failure::*;
|
||||
|
||||
use crate::tools;
|
||||
use crate::api::schema::*;
|
||||
use crate::api::router::*;
|
||||
use serde_json::{json, Value};
|
||||
|
|
|
@ -17,8 +17,6 @@ pub fn assemble_csrf_prevention_token(
|
|||
let epoch = std::time::SystemTime::now().duration_since(
|
||||
std::time::SystemTime::UNIX_EPOCH).unwrap().as_secs();
|
||||
|
||||
let timestamp = format!("{:08X}", epoch);
|
||||
|
||||
let mut hasher = sha::Sha256::new();
|
||||
let data = format!("{:08X}:{}:", epoch, username);
|
||||
hasher.update(data.as_bytes());
|
||||
|
|
|
@ -25,12 +25,12 @@ pub struct ArchiveIndexHeader {
|
|||
pub struct ArchiveIndexReader {
|
||||
store: Arc<ChunkStore>,
|
||||
_file: File,
|
||||
size: usize,
|
||||
pub size: usize,
|
||||
filename: PathBuf,
|
||||
index: *const u8,
|
||||
index_entries: usize,
|
||||
uuid: [u8; 16],
|
||||
ctime: u64,
|
||||
pub uuid: [u8; 16],
|
||||
pub ctime: u64,
|
||||
}
|
||||
|
||||
// fixme: ???!!!
|
||||
|
@ -324,8 +324,8 @@ pub struct ArchiveIndexWriter {
|
|||
closed: bool,
|
||||
filename: PathBuf,
|
||||
tmp_filename: PathBuf,
|
||||
uuid: [u8; 16],
|
||||
ctime: u64,
|
||||
pub uuid: [u8; 16],
|
||||
pub ctime: u64,
|
||||
|
||||
chunk_offset: usize,
|
||||
last_chunk: usize,
|
||||
|
|
|
@ -17,9 +17,9 @@ pub struct Chunker {
|
|||
|
||||
chunk_size_min: usize,
|
||||
chunk_size_max: usize,
|
||||
chunk_size_avg: usize,
|
||||
_chunk_size_avg: usize,
|
||||
|
||||
discriminator: u32,
|
||||
_discriminator: u32,
|
||||
|
||||
break_test_value: u32,
|
||||
|
||||
|
@ -123,8 +123,8 @@ impl Chunker {
|
|||
chunk_size: 0,
|
||||
chunk_size_min: chunk_size_avg>>2,
|
||||
chunk_size_max: chunk_size_avg<<2,
|
||||
chunk_size_avg: chunk_size_avg,
|
||||
discriminator: discriminator,
|
||||
_chunk_size_avg: chunk_size_avg,
|
||||
_discriminator: discriminator,
|
||||
break_test_value: break_test_value,
|
||||
window: [0u8; CA_CHUNKER_WINDOW_SIZE],
|
||||
}
|
||||
|
@ -199,6 +199,7 @@ impl Chunker {
|
|||
}
|
||||
|
||||
// This is the original implementation from casync
|
||||
/*
|
||||
#[inline(always)]
|
||||
fn shall_break_orig(&self) -> bool {
|
||||
|
||||
|
@ -208,7 +209,8 @@ impl Chunker {
|
|||
|
||||
(self.h % self.discriminator) == (self.discriminator - 1)
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
fn start(&mut self) {
|
||||
|
||||
let window_len = self.window.len();
|
||||
|
|
|
@ -7,8 +7,6 @@ use std::collections::HashMap;
|
|||
use lazy_static::lazy_static;
|
||||
use std::sync::{Mutex, Arc};
|
||||
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
use crate::tools;
|
||||
use crate::config::datastore;
|
||||
use super::chunk_store::*;
|
||||
|
|
|
@ -27,10 +27,10 @@ pub struct ImageIndexReader {
|
|||
store: Arc<ChunkStore>,
|
||||
filename: PathBuf,
|
||||
chunk_size: usize,
|
||||
size: usize,
|
||||
pub size: usize,
|
||||
index: *mut u8,
|
||||
uuid: [u8; 16],
|
||||
ctime: u64,
|
||||
pub uuid: [u8; 16],
|
||||
pub ctime: u64,
|
||||
}
|
||||
|
||||
impl Drop for ImageIndexReader {
|
||||
|
@ -160,8 +160,8 @@ pub struct ImageIndexWriter {
|
|||
duplicate_chunks: usize,
|
||||
size: usize,
|
||||
index: *mut u8,
|
||||
uuid: [u8; 16],
|
||||
ctime: u64,
|
||||
pub uuid: [u8; 16],
|
||||
pub ctime: u64,
|
||||
}
|
||||
|
||||
impl Drop for ImageIndexWriter {
|
||||
|
|
|
@ -23,14 +23,14 @@ fn main() {
|
|||
|
||||
for _i in 0..count {
|
||||
let mut pos = 0;
|
||||
let mut last = 0;
|
||||
let mut _last = 0;
|
||||
while pos < buffer.len() {
|
||||
let k = chunker.scan(&buffer[pos..]);
|
||||
if k == 0 {
|
||||
//println!("LAST {}", pos);
|
||||
break;
|
||||
} else {
|
||||
last = pos;
|
||||
_last = pos;
|
||||
pos += k;
|
||||
chunk_count += 1;
|
||||
//println!("CHUNK {} {}", pos, pos-last);
|
||||
|
|
|
@ -32,7 +32,7 @@ pub struct CaTarEncoder<'a, W: Write> {
|
|||
current_path: PathBuf, // used for error reporting
|
||||
writer: &'a mut W,
|
||||
writer_pos: usize,
|
||||
size: usize,
|
||||
_size: usize,
|
||||
file_copy_buffer: Vec<u8>,
|
||||
devices: Option<HashSet<u64>>,
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ impl <'a, W: Write> CaTarEncoder<'a, W> {
|
|||
current_path: path,
|
||||
writer: writer,
|
||||
writer_pos: 0,
|
||||
size: 0,
|
||||
_size: 0,
|
||||
file_copy_buffer,
|
||||
devices: None,
|
||||
};
|
||||
|
@ -553,36 +553,36 @@ nix::ioctl_read!(read_fat_attr_fd, b'r', 0x10, u32);
|
|||
|
||||
// from /usr/include/linux/magic.h
|
||||
// and from casync util.h
|
||||
const BINFMTFS_MAGIC: i64 = 0x42494e4d;
|
||||
const CGROUP2_SUPER_MAGIC: i64 = 0x63677270;
|
||||
const CGROUP_SUPER_MAGIC: i64 = 0x0027e0eb;
|
||||
const CONFIGFS_MAGIC: i64 = 0x62656570;
|
||||
const DEBUGFS_MAGIC: i64 = 0x64626720;
|
||||
const DEVPTS_SUPER_MAGIC: i64 = 0x00001cd1;
|
||||
const EFIVARFS_MAGIC: i64 = 0xde5e81e4;
|
||||
const FUSE_CTL_SUPER_MAGIC: i64 = 0x65735543;
|
||||
const HUGETLBFS_MAGIC: i64 = 0x958458f6;
|
||||
const MQUEUE_MAGIC: i64 = 0x19800202;
|
||||
const NFSD_MAGIC: i64 = 0x6e667364;
|
||||
const PROC_SUPER_MAGIC: i64 = 0x00009fa0;
|
||||
const PSTOREFS_MAGIC: i64 = 0x6165676C;
|
||||
const RPCAUTH_GSSMAGIC: i64 = 0x67596969;
|
||||
const SECURITYFS_MAGIC: i64 = 0x73636673;
|
||||
const SELINUX_MAGIC: i64 = 0xf97cff8c;
|
||||
const SMACK_MAGIC: i64 = 0x43415d53;
|
||||
const RAMFS_MAGIC: i64 = 0x858458f6;
|
||||
const TMPFS_MAGIC: i64 = 0x01021994;
|
||||
const SYSFS_MAGIC: i64 = 0x62656572;
|
||||
const MSDOS_SUPER_MAGIC: i64 = 0x00004d44;
|
||||
const FUSE_SUPER_MAGIC: i64 = 0x65735546;
|
||||
pub const BINFMTFS_MAGIC: i64 = 0x42494e4d;
|
||||
pub const CGROUP2_SUPER_MAGIC: i64 = 0x63677270;
|
||||
pub const CGROUP_SUPER_MAGIC: i64 = 0x0027e0eb;
|
||||
pub const CONFIGFS_MAGIC: i64 = 0x62656570;
|
||||
pub const DEBUGFS_MAGIC: i64 = 0x64626720;
|
||||
pub const DEVPTS_SUPER_MAGIC: i64 = 0x00001cd1;
|
||||
pub const EFIVARFS_MAGIC: i64 = 0xde5e81e4;
|
||||
pub const FUSE_CTL_SUPER_MAGIC: i64 = 0x65735543;
|
||||
pub const HUGETLBFS_MAGIC: i64 = 0x958458f6;
|
||||
pub const MQUEUE_MAGIC: i64 = 0x19800202;
|
||||
pub const NFSD_MAGIC: i64 = 0x6e667364;
|
||||
pub const PROC_SUPER_MAGIC: i64 = 0x00009fa0;
|
||||
pub const PSTOREFS_MAGIC: i64 = 0x6165676C;
|
||||
pub const RPCAUTH_GSSMAGIC: i64 = 0x67596969;
|
||||
pub const SECURITYFS_MAGIC: i64 = 0x73636673;
|
||||
pub const SELINUX_MAGIC: i64 = 0xf97cff8c;
|
||||
pub const SMACK_MAGIC: i64 = 0x43415d53;
|
||||
pub const RAMFS_MAGIC: i64 = 0x858458f6;
|
||||
pub const TMPFS_MAGIC: i64 = 0x01021994;
|
||||
pub const SYSFS_MAGIC: i64 = 0x62656572;
|
||||
pub const MSDOS_SUPER_MAGIC: i64 = 0x00004d44;
|
||||
pub const FUSE_SUPER_MAGIC: i64 = 0x65735546;
|
||||
|
||||
|
||||
#[inline(always)]
|
||||
fn is_temporary_file_system(magic: i64) -> bool {
|
||||
pub fn is_temporary_file_system(magic: i64) -> bool {
|
||||
magic == RAMFS_MAGIC || magic == TMPFS_MAGIC
|
||||
}
|
||||
|
||||
fn is_virtual_file_system(magic: i64) -> bool {
|
||||
pub fn is_virtual_file_system(magic: i64) -> bool {
|
||||
|
||||
match magic {
|
||||
BINFMTFS_MAGIC |
|
||||
|
|
|
@ -78,13 +78,8 @@ impl HttpClient {
|
|||
|
||||
pub fn upload(&self, content_type: &str, body: Body, path: &str) -> Result<Value, Error> {
|
||||
|
||||
let client = Client::new();
|
||||
|
||||
let url: Uri = format!("http://{}:8007/{}", self.server, path).parse()?;
|
||||
|
||||
use http::Request;
|
||||
use futures::stream::Stream;
|
||||
|
||||
let request = Request::builder()
|
||||
.method("POST")
|
||||
.uri(url)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
//! Generate and verify Authentification tickets
|
||||
|
||||
use crate::tools;
|
||||
|
||||
use failure::*;
|
||||
use std::path::PathBuf;
|
||||
use base64;
|
||||
|
||||
use openssl::rsa::{Rsa};
|
||||
use openssl::pkey::{PKey, Public, Private};
|
||||
use openssl::sign::{Signer, Verifier};
|
||||
use openssl::hash::MessageDigest;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use failure::*;
|
||||
//use failure::*;
|
||||
use tokio_threadpool;
|
||||
use std::io::Read;
|
||||
use futures::Async;
|
||||
|
@ -40,7 +40,7 @@ impl <R: Read> Stream for WrappedReaderStream<R> {
|
|||
},
|
||||
Ok(Async::Ready(Err(err))) => Err(err),
|
||||
Ok(Async::NotReady) => Ok(Async::NotReady),
|
||||
Err(err) => Err(blocking_err()),
|
||||
Err(_) => Err(blocking_err()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue