apply clippy suggestions
This commit is contained in:
parent
f41c2eb66b
commit
958466818b
12 changed files with 38 additions and 41 deletions
|
@ -22,9 +22,9 @@ pub async fn get_edit(data: web::Data<AppState>, id: web::Path<String>) -> HttpR
|
|||
let mut pastas = data.pastas.lock().unwrap();
|
||||
|
||||
let id = if ARGS.hash_ids {
|
||||
hashid_to_u64(&*id).unwrap_or(0)
|
||||
hashid_to_u64(&id).unwrap_or(0)
|
||||
} else {
|
||||
to_u64(&*id.into_inner()).unwrap_or(0)
|
||||
to_u64(&id.into_inner()).unwrap_or(0)
|
||||
};
|
||||
|
||||
remove_expired(&mut pastas);
|
||||
|
@ -38,7 +38,7 @@ pub async fn get_edit(data: web::Data<AppState>, id: web::Path<String>) -> HttpR
|
|||
}
|
||||
return HttpResponse::Ok().content_type("text/html").body(
|
||||
EditTemplate {
|
||||
pasta: &pasta,
|
||||
pasta,
|
||||
args: &ARGS,
|
||||
}
|
||||
.render()
|
||||
|
@ -65,9 +65,9 @@ pub async fn post_edit(
|
|||
}
|
||||
|
||||
let id = if ARGS.hash_ids {
|
||||
hashid_to_u64(&*id).unwrap_or(0)
|
||||
hashid_to_u64(&id).unwrap_or(0)
|
||||
} else {
|
||||
to_u64(&*id.into_inner()).unwrap_or(0)
|
||||
to_u64(&id.into_inner()).unwrap_or(0)
|
||||
};
|
||||
|
||||
let mut pastas = data.pastas.lock().unwrap();
|
||||
|
@ -77,20 +77,17 @@ pub async fn post_edit(
|
|||
let mut new_content = String::from("");
|
||||
|
||||
while let Some(mut field) = payload.try_next().await? {
|
||||
match field.name() {
|
||||
"content" => {
|
||||
while let Some(chunk) = field.try_next().await? {
|
||||
new_content = std::str::from_utf8(&chunk).unwrap().to_string();
|
||||
}
|
||||
if field.name() == "content" {
|
||||
while let Some(chunk) = field.try_next().await? {
|
||||
new_content = std::str::from_utf8(&chunk).unwrap().to_string();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
for (i, pasta) in pastas.iter().enumerate() {
|
||||
if pasta.id == id {
|
||||
if pasta.editable {
|
||||
pastas[i].content.replace_range(.., &*new_content);
|
||||
pastas[i].content.replace_range(.., &new_content);
|
||||
save_to_file(&pastas);
|
||||
|
||||
return Ok(HttpResponse::Found()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue