🚨 refactor: fix some Clippy lints

main
_ 2020-12-18 23:41:52 +00:00
parent d03c1a5476
commit 72b3b33206
2 changed files with 36 additions and 35 deletions

View File

@ -181,39 +181,39 @@ async fn serve_api (
{
use Response::*;
match prefix_match ("/v1/dir/", path) {
None => (),
Some (path) => {
let encoded_path = &path [0..];
// API versioning will be major-only, so I'll keep adding stuff to v1
// until I need to deprecate or break something.
let path_s = percent_decode (encoded_path.as_bytes ()).decode_utf8 ().map_err (FileServerError::PathNotUtf8)?;
let path = Path::new (&*path_s);
if let Some (path) = prefix_match ("/v1/dir/", path) {
let encoded_path = &path [0..];
let full_path = root.join (path);
let path_s = percent_decode (encoded_path.as_bytes ()).decode_utf8 ().map_err (FileServerError::PathNotUtf8)?;
let path = Path::new (&*path_s);
debug! ("full_path = {:?}", full_path);
let full_path = root.join (path);
if let Some (hidden_path) = hidden_path {
if full_path == hidden_path {
return Ok (Forbidden);
}
debug! ("full_path = {:?}", full_path);
if let Some (hidden_path) = hidden_path {
if full_path == hidden_path {
return Ok (Forbidden);
}
}
return if let Ok (dir) = read_dir (&full_path).await {
serve_dir (
&path_s,
path,
dir,
full_path,
&uri,
OutputFormat::Json
)
}
else {
Ok (NotFound)
};
},
};
return if let Ok (dir) = read_dir (&full_path).await {
serve_dir (
&path_s,
path,
dir,
full_path,
&uri,
OutputFormat::Json
)
}
else {
Ok (NotFound)
};
}
Ok (NotFound)
}

View File

@ -17,7 +17,7 @@ pub struct InstanceMetrics {
pub machine_id: Option <String>,
// Git version that ptth_server was built from (unimplemented)
pub _git_version: Option <String>,
pub git_version: Option <String>,
// User-assigned and human-readable name for this server.
// Must be unique within a relay.
@ -37,7 +37,7 @@ fn get_machine_id () -> Option <String> {
io::Read,
};
let mut buf = vec! [0u8; 1024];
let mut buf = vec! [0; 1024];
let mut f = File::open ("/etc/machine-id").ok ()?;
let bytes_read = f.read (&mut buf).ok ()?;
@ -50,11 +50,12 @@ fn get_machine_id () -> Option <String> {
}
impl InstanceMetrics {
#[must_use]
pub fn new (server_name: String) -> Self
{
Self {
machine_id: get_machine_id (),
_git_version: None,
git_version: None,
server_name,
instance_id: ulid::Ulid::new (),
startup_utc: Utc::now (),