🚨 refactor: fix some Clippy lints
parent
d03c1a5476
commit
72b3b33206
|
@ -181,9 +181,10 @@ async fn serve_api (
|
||||||
{
|
{
|
||||||
use Response::*;
|
use Response::*;
|
||||||
|
|
||||||
match prefix_match ("/v1/dir/", path) {
|
// API versioning will be major-only, so I'll keep adding stuff to v1
|
||||||
None => (),
|
// until I need to deprecate or break something.
|
||||||
Some (path) => {
|
|
||||||
|
if let Some (path) = prefix_match ("/v1/dir/", path) {
|
||||||
let encoded_path = &path [0..];
|
let encoded_path = &path [0..];
|
||||||
|
|
||||||
let path_s = percent_decode (encoded_path.as_bytes ()).decode_utf8 ().map_err (FileServerError::PathNotUtf8)?;
|
let path_s = percent_decode (encoded_path.as_bytes ()).decode_utf8 ().map_err (FileServerError::PathNotUtf8)?;
|
||||||
|
@ -212,8 +213,7 @@ async fn serve_api (
|
||||||
else {
|
else {
|
||||||
Ok (NotFound)
|
Ok (NotFound)
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Ok (NotFound)
|
Ok (NotFound)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub struct InstanceMetrics {
|
||||||
pub machine_id: Option <String>,
|
pub machine_id: Option <String>,
|
||||||
|
|
||||||
// Git version that ptth_server was built from (unimplemented)
|
// 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.
|
// User-assigned and human-readable name for this server.
|
||||||
// Must be unique within a relay.
|
// Must be unique within a relay.
|
||||||
|
@ -37,7 +37,7 @@ fn get_machine_id () -> Option <String> {
|
||||||
io::Read,
|
io::Read,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut buf = vec! [0u8; 1024];
|
let mut buf = vec! [0; 1024];
|
||||||
let mut f = File::open ("/etc/machine-id").ok ()?;
|
let mut f = File::open ("/etc/machine-id").ok ()?;
|
||||||
let bytes_read = f.read (&mut buf).ok ()?;
|
let bytes_read = f.read (&mut buf).ok ()?;
|
||||||
|
|
||||||
|
@ -50,11 +50,12 @@ fn get_machine_id () -> Option <String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InstanceMetrics {
|
impl InstanceMetrics {
|
||||||
|
#[must_use]
|
||||||
pub fn new (server_name: String) -> Self
|
pub fn new (server_name: String) -> Self
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
machine_id: get_machine_id (),
|
machine_id: get_machine_id (),
|
||||||
_git_version: None,
|
git_version: None,
|
||||||
server_name,
|
server_name,
|
||||||
instance_id: ulid::Ulid::new (),
|
instance_id: ulid::Ulid::new (),
|
||||||
startup_utc: Utc::now (),
|
startup_utc: Utc::now (),
|
||||||
|
|
Loading…
Reference in New Issue