Skip to content

Commit

Permalink
Log when a file is not served because it was too big
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 authored and Joshua Nelson committed Aug 2, 2020
1 parent cab5014 commit efdfa75
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/web/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,20 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
}

// 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
Expand Down

0 comments on commit efdfa75

Please sign in to comment.