From efdfa752cf07f1bab70647d3951d516b35a98e6a Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 2 Aug 2020 14:20:46 -0400 Subject: [PATCH] Log when a file is not served because it was too big --- src/web/rustdoc.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/web/rustdoc.rs b/src/web/rustdoc.rs index f4c3f2ae0..7b4367428 100644 --- a/src/web/rustdoc.rs +++ b/src/web/rustdoc.rs @@ -298,18 +298,20 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult { } // Attempt to load the file from the database - let file = if let Ok(file) = File::from_path(&storage, &path, &config) { - file - } else { - // If it fails, we try again with /index.html at the end - path.push_str("/index.html"); - req_path.push("index.html"); - - return if ctry!(req, storage.exists(&path)) { - redirect(&name, &version, &req_path[3..]) - } else { - Err(IronError::new(Nope::ResourceNotFound, status::NotFound)) - }; + let file = match File::from_path(&storage, &path, &config) { + Ok(file) => file, + Err(err) => { + log::debug!("got error serving {}: {}", path, err); + // If it fails, we try again with /index.html at the end + path.push_str("/index.html"); + req_path.push("index.html"); + + return if ctry!(req, storage.exists(&path)) { + redirect(&name, &version, &req_path[3..]) + } else { + Err(IronError::new(Nope::ResourceNotFound, status::NotFound)) + }; + } }; // Serve non-html files directly