cleanups: avoid compiler warnings
This commit is contained in:
parent
6c20a13d3c
commit
eae8aa3aa9
@ -17,7 +17,7 @@ pub struct ChunkStore {
|
|||||||
chunk_dir: PathBuf,
|
chunk_dir: PathBuf,
|
||||||
hasher: Sha512Trunc256,
|
hasher: Sha512Trunc256,
|
||||||
mutex: Mutex<bool>,
|
mutex: Mutex<bool>,
|
||||||
lockfile: File,
|
_lockfile: File,
|
||||||
}
|
}
|
||||||
|
|
||||||
const HEX_CHARS: &'static [u8; 16] = b"0123456789abcdef";
|
const HEX_CHARS: &'static [u8; 16] = b"0123456789abcdef";
|
||||||
@ -108,7 +108,7 @@ impl ChunkStore {
|
|||||||
base,
|
base,
|
||||||
chunk_dir,
|
chunk_dir,
|
||||||
hasher: Sha512Trunc256::new(),
|
hasher: Sha512Trunc256::new(),
|
||||||
lockfile,
|
_lockfile: lockfile,
|
||||||
mutex: Mutex::new(false)
|
mutex: Mutex::new(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -133,28 +133,26 @@ impl ChunkStore {
|
|||||||
let now = unsafe { libc::time(std::ptr::null_mut()) };
|
let now = unsafe { libc::time(std::ptr::null_mut()) };
|
||||||
|
|
||||||
for entry in handle.iter() {
|
for entry in handle.iter() {
|
||||||
match entry {
|
let entry = match entry {
|
||||||
Ok(entry) => {
|
Ok(entry) => entry,
|
||||||
if let Some(file_type) = entry.file_type() {
|
Err(_) => continue /* ignore */,
|
||||||
if file_type == nix::dir::Type::File {
|
};
|
||||||
let filename = entry.file_name();
|
let file_type = match entry.file_type() {
|
||||||
if let Ok(stat) = nix::sys::stat::fstatat(rawfd, filename, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW) {
|
Some(file_type) => file_type,
|
||||||
let age = now - stat.st_atime;
|
None => continue,
|
||||||
println!("FOUND {} {:?}", age/(3600*24), filename);
|
};
|
||||||
if age/(3600*24) >= 2 {
|
if file_type != nix::dir::Type::File { continue; }
|
||||||
println!("UNLINK {} {:?}", age/(3600*24), filename);
|
|
||||||
unsafe { libc::unlinkat(rawfd, filename.as_ptr(), 0); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
// fixme ??
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let filename = entry.file_name();
|
||||||
|
if let Ok(stat) = nix::sys::stat::fstatat(rawfd, filename, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW) {
|
||||||
|
let age = now - stat.st_atime;
|
||||||
|
println!("FOUND {} {:?}", age/(3600*24), filename);
|
||||||
|
if age/(3600*24) >= 2 {
|
||||||
|
println!("UNLINK {} {:?}", age/(3600*24), filename);
|
||||||
|
unsafe { libc::unlinkat(rawfd, filename.as_ptr(), 0); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sweep_used_chunks(&mut self) -> Result<(), Error> {
|
pub fn sweep_used_chunks(&mut self) -> Result<(), Error> {
|
||||||
@ -163,7 +161,7 @@ impl ChunkStore {
|
|||||||
use nix::sys::stat::Mode;
|
use nix::sys::stat::Mode;
|
||||||
use nix::dir::Dir;
|
use nix::dir::Dir;
|
||||||
|
|
||||||
let mut base_handle = match Dir::open(
|
let base_handle = match Dir::open(
|
||||||
&self.chunk_dir, OFlag::O_RDONLY, Mode::empty()) {
|
&self.chunk_dir, OFlag::O_RDONLY, Mode::empty()) {
|
||||||
Ok(h) => h,
|
Ok(h) => h,
|
||||||
Err(err) => bail!("unable to open base chunk dir {:?} - {}", self.chunk_dir, err),
|
Err(err) => bail!("unable to open base chunk dir {:?} - {}", self.chunk_dir, err),
|
||||||
|
@ -7,12 +7,12 @@ use apitest::tools;
|
|||||||
use apitest::cli::command::*;
|
use apitest::cli::command::*;
|
||||||
use apitest::api::schema::*;
|
use apitest::api::schema::*;
|
||||||
use apitest::api::router::*;
|
use apitest::api::router::*;
|
||||||
use apitest::backup::chunk_store::*;
|
//use apitest::backup::chunk_store::*;
|
||||||
use apitest::backup::image_index::*;
|
//use apitest::backup::image_index::*;
|
||||||
|
//use apitest::config::datastore;
|
||||||
use apitest::backup::datastore::*;
|
use apitest::backup::datastore::*;
|
||||||
use serde_json::{Value};
|
use serde_json::{Value};
|
||||||
|
|
||||||
use apitest::config::datastore;
|
|
||||||
|
|
||||||
fn required_string_param<'a>(param: &'a Value, name: &str) -> &'a str {
|
fn required_string_param<'a>(param: &'a Value, name: &str) -> &'a str {
|
||||||
param[name].as_str().expect(&format!("missing parameter '{}'", name))
|
param[name].as_str().expect(&format!("missing parameter '{}'", name))
|
||||||
|
@ -9,7 +9,7 @@ use std::io::Read;
|
|||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use std::os::unix::io::{RawFd, AsRawFd};
|
use std::os::unix::io::AsRawFd;
|
||||||
|
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
|
||||||
@ -173,5 +173,4 @@ pub fn file_chunker<C, R>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user