From 4c07f05b3a25fb894980e14d0d44e991cb7df0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 17 Sep 2019 21:05:56 +0200 Subject: [PATCH] Remove Result in preparation of deprecation as Rocket responder. Removed unnecessary returns --- src/api/web.rs | 13 ++++++------- src/db/models/attachment.rs | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/api/web.rs b/src/api/web.rs index a9624f96..d80355e1 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -1,4 +1,3 @@ -use std::io; use std::path::{Path, PathBuf}; use rocket::http::ContentType; @@ -21,10 +20,10 @@ pub fn routes() -> Vec { } #[get("/")] -fn web_index() -> Cached> { +fn web_index() -> Cached> { Cached::short(NamedFile::open( Path::new(&CONFIG.web_vault_folder()).join("index.html"), - )) + ).ok()) } #[get("/app-id.json")] @@ -47,13 +46,13 @@ fn app_id() -> Cached>> { } #[get("/", rank = 10)] // Only match this if the other routes don't match -fn web_files(p: PathBuf) -> Cached> { - Cached::long(NamedFile::open(Path::new(&CONFIG.web_vault_folder()).join(p))) +fn web_files(p: PathBuf) -> Cached> { + Cached::long(NamedFile::open(Path::new(&CONFIG.web_vault_folder()).join(p)).ok()) } #[get("/attachments//")] -fn attachments(uuid: String, file: PathBuf) -> io::Result { - NamedFile::open(Path::new(&CONFIG.attachments_folder()).join(uuid).join(file)) +fn attachments(uuid: String, file: PathBuf) -> Option { + NamedFile::open(Path::new(&CONFIG.attachments_folder()).join(uuid).join(file)).ok() } #[get("/alive")] diff --git a/src/db/models/attachment.rs b/src/db/models/attachment.rs index 0f8e495f..03064863 100644 --- a/src/db/models/attachment.rs +++ b/src/db/models/attachment.rs @@ -61,7 +61,7 @@ use crate::error::MapResult; impl Attachment { #[cfg(feature = "postgresql")] pub fn save(&self, conn: &DbConn) -> EmptyResult { - return diesel::insert_into(attachments::table) + diesel::insert_into(attachments::table) .values(self) .on_conflict(attachments::id) .do_update() @@ -72,7 +72,7 @@ impl Attachment { #[cfg(not(feature = "postgresql"))] pub fn save(&self, conn: &DbConn) -> EmptyResult { - return diesel::replace_into(attachments::table) + diesel::replace_into(attachments::table) .values(self) .execute(&**conn) .map_res("Error saving attachment")