]> OzVa Git service - ozva-cloud/commitdiff
chore: fix typos and clippy (#379)
authorsigoden <sigoden@gmail.com>
Sat, 4 May 2024 22:23:18 +0000 (06:23 +0800)
committerGitHub <noreply@github.com>
Sat, 4 May 2024 22:23:18 +0000 (06:23 +0800)
assets/favicon.ico [changed mode: 0755->0644]
src/args.rs
tests/auth.rs
tests/http.rs
tests/utils.rs

old mode 100755 (executable)
new mode 100644 (file)
index 9027051750bf8887ec00afbaac5c6835c0ff7a00..f26dbcaf64117b37cfe568d41bdf2b046989d3cb 100644 (file)
@@ -301,7 +301,7 @@ impl Args {
         }
 
         if let Some(path) = matches.get_one::<PathBuf>("serve-path") {
-            args.serve_path = path.clone()
+            args.serve_path.clone_from(path)
         }
 
         args.serve_path = Self::sanitize_path(args.serve_path)?;
@@ -317,7 +317,7 @@ impl Args {
 
         args.path_is_file = args.serve_path.metadata()?.is_file();
         if let Some(path_prefix) = matches.get_one::<String>("path-prefix") {
-            args.path_prefix = path_prefix.clone();
+            args.path_prefix.clone_from(path_prefix)
         }
         args.path_prefix = args.path_prefix.trim_matches('/').to_string();
 
index adaf63f347a350f9859a9aa5590a0951886b1501..39e3b6d26d1fe69980f17490386062eda0901464 100644 (file)
@@ -299,14 +299,14 @@ fn auth_data(
 ) -> Result<(), Error> {
     let resp = reqwest::blocking::get(server.url())?;
     let content = resp.text()?;
-    let json = utils::retrive_json(&content).unwrap();
+    let json = utils::retrieve_json(&content).unwrap();
     assert_eq!(json["allow_delete"], serde_json::Value::Bool(false));
     assert_eq!(json["allow_upload"], serde_json::Value::Bool(false));
     let resp = fetch!(b"GET", server.url())
         .basic_auth("user", Some("pass"))
         .send()?;
     let content = resp.text()?;
-    let json = utils::retrive_json(&content).unwrap();
+    let json = utils::retrieve_json(&content).unwrap();
     assert_eq!(json["allow_delete"], serde_json::Value::Bool(true));
     assert_eq!(json["allow_upload"], serde_json::Value::Bool(true));
     Ok(())
index 8ea58947510ea4496d4db796c3fbf69ce594bb73..c2b0566a063574a90aeddd0ab7ba8120b6774509 100644 (file)
@@ -4,7 +4,7 @@ mod utils;
 use fixtures::{server, Error, TestServer, BIN_FILE};
 use rstest::rstest;
 use serde_json::Value;
-use utils::retrive_edit_file;
+use utils::retrieve_edit_file;
 
 #[rstest]
 fn get_dir(server: TestServer) -> Result<(), Error> {
@@ -238,7 +238,7 @@ fn get_file_newline_path(server: TestServer) -> Result<(), Error> {
 fn get_file_edit(server: TestServer) -> Result<(), Error> {
     let resp = fetch!(b"GET", format!("{}index.html?edit", server.url())).send()?;
     assert_eq!(resp.status(), 200);
-    let editable = retrive_edit_file(&resp.text().unwrap()).unwrap();
+    let editable = retrieve_edit_file(&resp.text().unwrap()).unwrap();
     assert!(editable);
     Ok(())
 }
@@ -247,7 +247,7 @@ fn get_file_edit(server: TestServer) -> Result<(), Error> {
 fn get_file_edit_bin(server: TestServer) -> Result<(), Error> {
     let resp = fetch!(b"GET", format!("{}{BIN_FILE}?edit", server.url())).send()?;
     assert_eq!(resp.status(), 200);
-    let editable = retrive_edit_file(&resp.text().unwrap()).unwrap();
+    let editable = retrieve_edit_file(&resp.text().unwrap()).unwrap();
     assert!(!editable);
     Ok(())
 }
index c987050a45cd9db876a6fbb0127b412fe93f4fb0..590ab78626fb2967c59aaa6a61d4d441a0acd35e 100644 (file)
@@ -26,7 +26,7 @@ macro_rules! fetch {
 
 #[allow(dead_code)]
 pub fn retrieve_index_paths(content: &str) -> IndexSet<String> {
-    let value = retrive_json(content).unwrap();
+    let value = retrieve_json(content).unwrap();
     let paths = value
         .get("paths")
         .unwrap()
@@ -47,8 +47,8 @@ pub fn retrieve_index_paths(content: &str) -> IndexSet<String> {
 }
 
 #[allow(dead_code)]
-pub fn retrive_edit_file(content: &str) -> Option<bool> {
-    let value = retrive_json(content)?;
+pub fn retrieve_edit_file(content: &str) -> Option<bool> {
+    let value = retrieve_json(content)?;
     let value = value.get("editable").unwrap();
     Some(value.as_bool().unwrap())
 }
@@ -60,7 +60,7 @@ pub fn encode_uri(v: &str) -> String {
 }
 
 #[allow(dead_code)]
-pub fn retrive_json(content: &str) -> Option<Value> {
+pub fn retrieve_json(content: &str) -> Option<Value> {
     let lines: Vec<&str> = content.lines().collect();
     let line = lines.iter().find(|v| v.contains("DATA ="))?;
     let line_col = line.find("DATA =").unwrap() + 6;