Skip to content

Log when a file is not served because it was too big #932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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