Skip to content

Commit 46e5331

Browse files
Only attempt an S3 request if this row is in S3
1 parent 6db1a46 commit 46e5331

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/db/file.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,21 @@ pub fn get_path(conn: &Connection, path: &str) -> Option<Blob> {
7070
if rows.len() == 0 {
7171
None
7272
} else {
73-
let client = s3_client();
7473
let row = rows.get(0);
75-
let content = client.and_then(|c| c.get_object(GetObjectRequest {
76-
bucket: "rust-docs-rs".into(),
77-
key: path.into(),
78-
..Default::default()
79-
}).sync().ok()).and_then(|r| r.body).map(|b| {
80-
let mut b = b.into_blocking_read();
81-
let mut content = Vec::new();
82-
b.read_to_end(&mut content).unwrap();
83-
content
84-
}).unwrap_or(row.get(3));
74+
let mut content = row.get(3);
75+
if content == b"in-s3" {
76+
let client = s3_client();
77+
content = client.and_then(|c| c.get_object(GetObjectRequest {
78+
bucket: "rust-docs-rs".into(),
79+
key: path.into(),
80+
..Default::default()
81+
}).sync().ok()).and_then(|r| r.body).map(|b| {
82+
let mut b = b.into_blocking_read();
83+
let mut content = Vec::new();
84+
b.read_to_end(&mut content).unwrap();
85+
content
86+
}).unwrap();
87+
};
8588

8689
Some(Blob {
8790
path: row.get(0),

0 commit comments

Comments
 (0)