Fix some clippy complaints.
This commit is contained in:
parent
8ae2c64564
commit
a54ca58850
@ -52,9 +52,9 @@ fn register_photo(
|
||||
) -> Result<Photo, DieselError> {
|
||||
use schema::photos::dsl::{is_public, photos};
|
||||
let photo = match Photo::create_or_set_basics(db, tpath, None, 0, None)? {
|
||||
Modification::Created(photo) => photo,
|
||||
Modification::Updated(photo) => photo,
|
||||
Modification::Unchanged(photo) => photo,
|
||||
Modification::Created(photo)
|
||||
| Modification::Updated(photo)
|
||||
| Modification::Unchanged(photo) => photo,
|
||||
};
|
||||
update(photos.find(photo.id))
|
||||
.set(is_public.eq(true))
|
||||
|
@ -28,5 +28,5 @@ pub fn photos_dir() -> PathBuf {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn env_or(name: &str, default: &str) -> String {
|
||||
var(name).unwrap_or(default.to_string())
|
||||
var(name).unwrap_or_else(|_err| default.to_string())
|
||||
}
|
||||
|
@ -30,11 +30,10 @@ impl PhotosDir {
|
||||
img
|
||||
};
|
||||
let img = match photo.rotation {
|
||||
_x @ 0...44 => img,
|
||||
_x @ 0...44 | _x @ 315...360 => img,
|
||||
_x @ 45...134 => img.rotate90(),
|
||||
_x @ 135...224 => img.rotate180(),
|
||||
_x @ 225...314 => img.rotate270(),
|
||||
_x @ 315...360 => img,
|
||||
x => {
|
||||
warn!("Should rotate photo {} deg, which is unsupported", x);
|
||||
img
|
||||
|
@ -66,11 +66,11 @@ impl PhotoLink {
|
||||
g.last()
|
||||
.and_then(|p| p.date)
|
||||
.map(|d| format!("{}", d.format("%F %T")))
|
||||
.unwrap_or("-".into()),
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
g.first()
|
||||
.and_then(|p| p.date)
|
||||
.map(|d| format!("{}", d.format("%F %T")))
|
||||
.unwrap_or("-".into()),
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
g.len(),
|
||||
)),
|
||||
}
|
||||
@ -199,7 +199,7 @@ fn do_login<'mw>(
|
||||
if djangohashers::check_password_tolerant(pw, &hash) {
|
||||
info!("User {} logged in", user);
|
||||
res.set_jwt_user(user);
|
||||
return res.redirect(next.unwrap_or("/".to_string()));
|
||||
return res.redirect(next.unwrap_or_else(|| "/".into()));
|
||||
}
|
||||
info!(
|
||||
"Login failed: Password verification failed for {:?}",
|
||||
|
@ -49,7 +49,7 @@ pub fn all_years<'mw>(
|
||||
};
|
||||
Group {
|
||||
title: year.map(|y| format!("{}", y))
|
||||
.unwrap_or("-".to_string()),
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
url: format!("/{}/", year.unwrap_or(0)),
|
||||
count: count,
|
||||
photo: photo.first::<Photo>(c).unwrap(),
|
||||
|
Loading…
Reference in New Issue
Block a user