aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-10-28 14:03:05 +0200
committerMartin Fischer <martin@push-f.com>2022-10-28 14:03:05 +0200
commit95aa0534320a6b077a6063b612a099dd3d9d4145 (patch)
treecd6e0ab7de62bb8b53a2afed9a184f3adcb9e5f2
parent6d2b42da54335682bf5ba25277323daafca16808 (diff)
refactor: some linter fixes
-rw-r--r--src/controller.rs20
-rw-r--r--src/forms.rs4
-rw-r--r--src/get_routes.rs5
-rw-r--r--src/lua/template.rs4
-rw-r--r--src/main.rs2
-rw-r--r--src/shares.rs4
6 files changed, 18 insertions, 21 deletions
diff --git a/src/controller.rs b/src/controller.rs
index 9127900..42520f4 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -395,16 +395,14 @@ impl Controller for MultiUserController {
parts: &Parts,
) {
let username = username_from_parts(parts).unwrap();
- if context.branch.0 == username {
- if context.path.components().count() == 0 {
- match tree {
- None => page.body.push_str(EMPTY_HOME_HINT),
- Some(tree) => {
- if tree.iter().count() == 0 {
- page.body.push_str(EMPTY_HOME_HINT);
- } else if tree.get_path(Path::new(".shares.txt")).is_err() {
- page.body.push_str("<p>Share files with other users by <a href='.shares.txt?action=edit'>creating a .shares.txt</a> config.</p>");
- }
+ if context.branch.0 == username && context.path.components().count() == 0 {
+ match tree {
+ None => page.body.push_str(EMPTY_HOME_HINT),
+ Some(tree) => {
+ if tree.iter().count() == 0 {
+ page.body.push_str(EMPTY_HOME_HINT);
+ } else if tree.get_path(Path::new(".shares.txt")).is_err() {
+ page.body.push_str("<p>Share files with other users by <a href='.shares.txt?action=edit'>creating a .shares.txt</a> config.</p>");
}
}
}
@@ -433,7 +431,7 @@ impl Controller for MultiUserController {
let mut ok = false;
self.with_shares_cache(&ctx.repo, ctx.branch.clone(), |shares| {
- if let Some(mode) = shares.find_mode(ctx.path.as_str(), username) {
+ if let Some(_mode) = shares.find_mode(ctx.path.as_str(), username) {
ok = true;
}
});
diff --git a/src/forms.rs b/src/forms.rs
index 0a2019c..6328738 100644
--- a/src/forms.rs
+++ b/src/forms.rs
@@ -43,7 +43,7 @@ pub fn edit_text_form<'a, C: Controller>(
script_src: vec![include_str!("static/edit_script.js.sha")],
..Default::default()
};
- if let Some(access_info_html) = controller.access_info_html(&ctx, parts) {
+ if let Some(access_info_html) = controller.access_info_html(ctx, parts) {
page.body.push_str(&access_info_html);
}
if let Some(hint_html) = controller.edit_hint_html(ctx) {
@@ -137,7 +137,7 @@ pub fn upload_form<'a, C: Controller>(
</form>"
.into(),
header: file_exists
- .then(|| action_links("edit", controller, &ctx, parts))
+ .then(|| action_links("edit", controller, ctx, parts))
.unwrap_or_default(),
..Default::default()
}
diff --git a/src/get_routes.rs b/src/get_routes.rs
index 10d3476..8290623 100644
--- a/src/get_routes.rs
+++ b/src/get_routes.rs
@@ -42,7 +42,7 @@ pub(crate) fn get_blob<C: Controller>(
"raw" => raw_blob(entr, params, controller, ctx, parts).map(|r| r.into()),
"run" => run_blob(entr, params, controller, ctx, parts).map(|r| r.into()),
"move" => move_blob(entr, params, controller, ctx, parts),
- "remove" => remove_blob(entr, params, controller, ctx, parts),
+ "remove" => remove_blob(params, controller, ctx, parts),
_ => Err(Error::BadRequest("unknown action".into())),
}
}
@@ -233,7 +233,7 @@ fn diff_blob<C: Controller>(
.ok_or_else(|| Error::NotFound("commit not found".into()))?;
let old_commit = if let Some(oldid) = &params.oldid {
- let other_commit = find_commit(&ctx.repo, &oldid, &branch_commit.id())
+ let other_commit = find_commit(&ctx.repo, oldid, &branch_commit.id())
.ok_or_else(|| Error::NotFound("commit not found".into()))?;
if other_commit.time() > commit.time() {
@@ -410,7 +410,6 @@ fn move_blob<C: Controller>(
}
fn remove_blob<C: Controller>(
- entr: TreeEntry,
params: ActionParam,
controller: &C,
ctx: Context,
diff --git a/src/lua/template.rs b/src/lua/template.rs
index de13481..99dfded 100644
--- a/src/lua/template.rs
+++ b/src/lua/template.rs
@@ -94,9 +94,9 @@ impl<'a> ParserState<'a> {
match tok {
MarkerToken::StripMarker => match usize::from_str_radix(&lex.slice()[6..11], 16) {
Ok(idx) => {
- render(&self.substitutions[idx], &mut out);
+ let _ = render(&self.substitutions[idx], &mut out);
}
- Err(e) => out.push_str(lex.slice()),
+ Err(_) => out.push_str(lex.slice()),
},
MarkerToken::Other => out.push_str(lex.slice()),
}
diff --git a/src/main.rs b/src/main.rs
index e82cfae..a08d192 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -348,7 +348,7 @@ async fn build_response<C: Controller>(
let mut comps = Vec::new();
// prevent directory traversal attacks
- for comp in Utf8Path::new(&*unsanitized_path).components() {
+ for comp in Utf8Path::new(unsanitized_path).components() {
match comp {
Utf8Component::Normal(name) => comps.push(name),
Utf8Component::ParentDir => {
diff --git a/src/shares.rs b/src/shares.rs
index 4017e1f..a6831dc 100644
--- a/src/shares.rs
+++ b/src/shares.rs
@@ -40,7 +40,7 @@ pub struct AccessRule {
pub end: usize,
}
-#[derive(PartialEq, Debug)]
+#[derive(PartialEq, Eq, Debug)]
pub enum AccessMode {
ReadAndWrite,
ReadOnly,
@@ -148,7 +148,7 @@ pub fn parse_shares_txt(text: &str) -> Result<Shares, String> {
// normalize path
let mut comps = Vec::new();
- for comp in Utf8Path::new(&*path).components() {
+ for comp in Utf8Path::new(path).components() {
match comp {
Utf8Component::Normal(name) => comps.push(name),
Utf8Component::ParentDir => {