Skip to content

Commit

Permalink
Give precedence to local shared files over global ones
Browse files Browse the repository at this point in the history
When serving 'essential files', we can either serve the global one,
created when building `empty_library`, or the local one, created when
building the local crate. Currently we default to the global one, but
this causes issues when the file should never have been global in the
first place (such as recently for `crates.js`: see
#1313).

This gives precedence to the local file so that the bug will be fixed
when rustdoc fixes it, even if we forget to update
`ESSENTIAL_FILES_UNVERSIONED`.
  • Loading branch information
jyn514 committed Mar 20, 2021
1 parent 4ee9d89 commit 01972f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ impl Handler for CratesfyiHandler {
// try serving shared rustdoc resources first, then db/static file handler and last router
// return 404 if none of them return Ok. It is important that the router comes last,
// because it gives the most specific errors, e.g. CrateNotFound or VersionNotFound
self.shared_resource_handler
self.router_handler
.handle(req)
.or_else(|e| if_404(e, || self.router_handler.handle(req)))
.or_else(|e| if_404(e, || self.shared_resource_handler.handle(req)))
.or_else(|e| if_404(e, || self.database_file_handler.handle(req)))
.or_else(|e| {
let err = if let Some(err) = e.error.downcast_ref::<error::Nope>() {
Expand Down

0 comments on commit 01972f6

Please sign in to comment.