Skip to content

Commit 6faf536

Browse files
committed
clean
1 parent 4f55c51 commit 6faf536

File tree

5 files changed

+21
-26
lines changed

5 files changed

+21
-26
lines changed

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{Context as _, Error, Result, bail};
1+
use anyhow::{Context as _, Error, Result};
22
use std::{env, fs::File, io::Write as _, path::Path};
33

44
mod tracked {
@@ -163,7 +163,7 @@ fn compile_sass(out_dir: &Path, etag_map: &mut ETagMap) -> Result<()> {
163163
for entry in walkdir::WalkDir::new(STYLE_DIR) {
164164
let entry = entry?;
165165
if entry.metadata()?.is_dir() {
166-
bail!("directories are not supported in {}", STYLE_DIR);
166+
tracked::track(entry.path())?;
167167
} else {
168168
let file_name = entry
169169
.file_name()

src/storage/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ impl StreamingBlob {
153153
impl From<Blob> for StreamingBlob {
154154
fn from(value: Blob) -> Self {
155155
Self {
156-
path: self.path,
157-
mime: self.mime,
158-
date_updated: self.date_updated,
159-
etag: self.etag,
160-
compression: self.compression,
161-
content_length: self.content.len(),
162-
content: Box::new(io::Cursor::new(self.content)),
156+
path: value.path,
157+
mime: value.mime,
158+
date_updated: value.date_updated,
159+
etag: value.etag,
160+
compression: value.compression,
161+
content_length: value.content.len(),
162+
content: Box::new(io::Cursor::new(value.content)),
163163
}
164164
}
165165
}
@@ -1291,10 +1291,7 @@ pub(crate) fn source_archive_path(name: &str, version: &Version) -> String {
12911291
#[cfg(test)]
12921292
mod test {
12931293
use super::*;
1294-
use crate::{
1295-
test::{TestEnvironment, V0_1},
1296-
web::headers::compute_etag,
1297-
};
1294+
use crate::{test::TestEnvironment, web::headers::compute_etag};
12981295
use std::env;
12991296
use test_case::test_case;
13001297

src/web/file.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ use crate::{
99
use axum::{
1010
body::Body,
1111
extract::Extension,
12-
http::{
13-
StatusCode,
14-
header::{CONTENT_TYPE, LAST_MODIFIED},
15-
},
12+
http::StatusCode,
1613
response::{IntoResponse, Response as AxumResponse},
1714
};
1815
use axum_extra::{
1916
TypedHeader,
20-
headers::{ContentType, HeaderMapExt, IfNoneMatch, LastModified},
17+
headers::{ContentType, IfNoneMatch, LastModified},
2118
};
22-
use std::{io, time::SystemTime};
19+
use std::time::SystemTime;
2320
use tokio_util::io::ReaderStream;
2421

2522
#[derive(Debug)]
@@ -44,7 +41,8 @@ impl File {
4441

4542
impl File {
4643
pub fn into_response(self, if_none_match: Option<IfNoneMatch>) -> AxumResponse {
47-
StreamingFile(self.0.into().into_response(if_none_match))
44+
let streaming_blob: StreamingBlob = self.0.into();
45+
StreamingFile(streaming_blob).into_response(if_none_match)
4846
}
4947
}
5048

@@ -91,7 +89,7 @@ mod tests {
9189
use super::*;
9290
use crate::test::TestEnvironment;
9391
use chrono::Utc;
94-
use http::header::CACHE_CONTROL;
92+
use http::header::{CACHE_CONTROL, LAST_MODIFIED};
9593
use std::rc::Rc;
9694

9795
#[tokio::test(flavor = "multi_thread")]

src/web/rustdoc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ use axum::{
3636
response::{IntoResponse, Response as AxumResponse},
3737
};
3838
use axum_extra::{
39-
TypedHeader,
4039
headers::{ContentType, IfNoneMatch},
40+
typed_header::TypedHeader,
4141
};
42-
use http::{HeaderValue, Uri, header, uri::Authority};
42+
use http::{Uri, uri::Authority};
4343
use serde::Deserialize;
4444
use std::{
4545
collections::HashMap,
@@ -440,7 +440,6 @@ pub(crate) async fn rustdoc_html_server_handler(
440440
Extension(config): Extension<Arc<Config>>,
441441
Extension(csp): Extension<Arc<Csp>>,
442442
RawQuery(original_query): RawQuery,
443-
// FIXME: perhaps our own extractor so we get a real Option<TH<INM>>?
444443
if_none_match: Option<TypedHeader<IfNoneMatch>>,
445444
mut conn: DbConnection,
446445
) -> AxumResult<AxumResponse> {

src/web/statics.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use axum::{
88
routing::get_service,
99
};
1010
use axum_extra::{
11-
TypedHeader,
1211
headers::{ETag, HeaderMapExt as _, HeaderValue, IfNoneMatch},
12+
typed_header::TypedHeader,
1313
};
1414
use http::{Method, StatusCode, Uri};
1515
use tower_http::services::ServeDir;
@@ -60,10 +60,11 @@ async fn set_needed_static_headers(req: Request, next: Next) -> Response {
6060
async fn conditional_get(
6161
partial_uri: Uri,
6262
method: Method,
63-
TypedHeader(if_none_match): TypedHeader<IfNoneMatch>,
63+
if_none_match: Option<TypedHeader<IfNoneMatch>>,
6464
req: Request,
6565
next: Next,
6666
) -> Response {
67+
let if_none_match = if_none_match.map(|th| th.0);
6768
let resource_path = partial_uri.path().trim_start_matches('/');
6869
let Some(etag) = STATIC_ETAG_MAP.get(resource_path).map(|etag| {
6970
etag.parse::<ETag>()

0 commit comments

Comments
 (0)