Fix clippy warnings
This commit is contained in:
10
src/files.rs
10
src/files.rs
@@ -345,8 +345,8 @@ mod tests {
|
||||
let tag2 = tag_dao.create_tag("tag2").unwrap();
|
||||
let tag3 = tag_dao.create_tag("tag3").unwrap();
|
||||
|
||||
&tag_dao.tag_file("test.jpg", tag1.id).unwrap();
|
||||
&tag_dao.tag_file("test.jpg", tag3.id).unwrap();
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag1.id).unwrap();
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag3.id).unwrap();
|
||||
|
||||
let mut files = HashMap::new();
|
||||
files.insert(
|
||||
@@ -390,11 +390,11 @@ mod tests {
|
||||
let mut tag_dao = SqliteTagDao::new(in_memory_db_connection());
|
||||
|
||||
let tag1 = tag_dao.create_tag("tag1").unwrap();
|
||||
let tag2 = tag_dao.create_tag("tag2").unwrap();
|
||||
let _tag2 = tag_dao.create_tag("tag2").unwrap();
|
||||
let tag3 = tag_dao.create_tag("tag3").unwrap();
|
||||
|
||||
&tag_dao.tag_file("test.jpg", tag1.id).unwrap();
|
||||
&tag_dao.tag_file("test.jpg", tag3.id).unwrap();
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag1.id).unwrap();
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag3.id).unwrap();
|
||||
|
||||
// Should get filtered since it doesn't have tag3
|
||||
tag_dao.tag_file("some-other.jpg", tag1.id).unwrap();
|
||||
|
||||
@@ -216,7 +216,7 @@ async fn stream_video(
|
||||
debug!("Playlist: {}", playlist);
|
||||
|
||||
// Extract video playlist dir to dotenv
|
||||
if !playlist.starts_with("tmp") && is_valid_full_path(&app_state.base_path, playlist) != None {
|
||||
if !playlist.starts_with("tmp") && is_valid_full_path(&app_state.base_path, playlist).is_some() {
|
||||
HttpResponse::BadRequest().finish()
|
||||
} else if let Ok(file) = NamedFile::open(playlist) {
|
||||
file.into_response(&request)
|
||||
@@ -363,7 +363,7 @@ fn create_thumbnails() {
|
||||
if ext == "mp4" || ext == "mov" {
|
||||
let relative_path = &entry.path().strip_prefix(&images).unwrap();
|
||||
let thumb_path = Path::new(thumbnail_directory).join(relative_path);
|
||||
std::fs::create_dir_all(&thumb_path.parent().unwrap())
|
||||
std::fs::create_dir_all(thumb_path.parent().unwrap_or_else(|| panic!("Thumbnail {:?} has no parent?", thumb_path)))
|
||||
.expect("Error creating directory");
|
||||
|
||||
debug!("Generating video thumbnail: {:?}", thumb_path);
|
||||
@@ -395,7 +395,7 @@ fn create_thumbnails() {
|
||||
.map(|(image, path)| {
|
||||
let relative_path = &path.strip_prefix(&images).unwrap();
|
||||
let thumb_path = Path::new(thumbnail_directory).join(relative_path);
|
||||
std::fs::create_dir_all(&thumb_path.parent().unwrap())
|
||||
std::fs::create_dir_all(thumb_path.parent().unwrap())
|
||||
.expect("There was an issue creating directory");
|
||||
debug!("Saving thumbnail: {:?}", thumb_path);
|
||||
image.save(thumb_path).expect("Failure saving thumbnail");
|
||||
|
||||
12
src/tags.rs
12
src/tags.rs
@@ -92,10 +92,10 @@ async fn update_tags<D: TagDao>(
|
||||
) -> impl Responder {
|
||||
let mut dao = tag_dao.lock().expect("Unable to get TagDao");
|
||||
|
||||
return dao
|
||||
dao
|
||||
.get_tags_for_path(&request.file_name)
|
||||
.and_then(|existing_tags| dao.get_all_tags().map(|all| (existing_tags, all)))
|
||||
.and_then(|(existing_tags, all_tags)| {
|
||||
.map(|(existing_tags, all_tags)| {
|
||||
let tags_to_remove = existing_tags
|
||||
.iter()
|
||||
.filter(|&t| !request.tag_ids.contains(&t.id))
|
||||
@@ -107,7 +107,7 @@ async fn update_tags<D: TagDao>(
|
||||
tag.name, request.file_name
|
||||
);
|
||||
dao.remove_tag(&tag.name, &request.file_name)
|
||||
.expect(&format!("Unable to remove tag {:?}", &tag.name));
|
||||
.unwrap_or_else(|err| panic!("{:?} Unable to remove tag {:?}", err, &tag.name));
|
||||
}
|
||||
|
||||
let new_tags = all_tags
|
||||
@@ -131,9 +131,9 @@ async fn update_tags<D: TagDao>(
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok())
|
||||
HttpResponse::Ok()
|
||||
})
|
||||
.into_http_internal_err();
|
||||
.into_http_internal_err()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Queryable, Clone, Debug, PartialEq)]
|
||||
@@ -288,7 +288,7 @@ impl TagDao for SqliteTagDao {
|
||||
.and_then(|tagged_id| {
|
||||
debug!("Inserted tagged photo: {:?}", tagged_id);
|
||||
tagged_photo::table
|
||||
.find(tagged_id as i32)
|
||||
.find(tagged_id)
|
||||
.first(self.connection.borrow_mut())
|
||||
.with_context(|| {
|
||||
format!(
|
||||
|
||||
Reference in New Issue
Block a user