Commit
+16 -18 +/-5 browse
1 | diff --git a/src/error.rs b/src/error.rs |
2 | index 23f4229..dbbe191 100644 |
3 | --- a/src/error.rs |
4 | +++ b/src/error.rs |
5 | @@ -31,8 +31,8 @@ pub enum Error { |
6 | Http(http::Error), |
7 | Hyper(hyper::Error), |
8 | Json(serde_json::Error), |
9 | - Sha256Error(Sha256Error), |
10 | - Sha256VerifyError(Sha256VerifyError), |
11 | + Sha256(Sha256Error), |
12 | + Sha256Verify(Sha256VerifyError), |
13 | S3(storage::S3Error), |
14 | S3DiskCache(<storage::S3DiskCache as Storage>::Error), |
15 | Askama(askama::Error), |
16 | diff --git a/src/lib.rs b/src/lib.rs |
17 | index 2b53bd1..8c0d2db 100644 |
18 | --- a/src/lib.rs |
19 | +++ b/src/lib.rs |
20 | @@ -17,6 +17,8 @@ |
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
23 | // SOFTWARE. |
24 | + #![deny(clippy::all)] |
25 | + |
26 | mod app; |
27 | mod error; |
28 | mod hyperext; |
29 | @@ -144,7 +146,7 @@ impl S3ServerBuilder { |
30 | through Rudolfs in this case, they will *not* be encrypted." |
31 | ); |
32 | |
33 | - if let Some(_) = self.cache.take() { |
34 | + if self.cache.take().is_some() { |
35 | log::warn!( |
36 | "A local disk cache does not work with a CDN and will be \ |
37 | disabled." |
38 | @@ -276,5 +278,5 @@ where |
39 | future::ok::<_, Infallible>(Logger::new(socket.remote_addr(), service)) |
40 | }); |
41 | |
42 | - hyper::Server::bind(&addr).serve(new_service) |
43 | + hyper::Server::bind(addr).serve(new_service) |
44 | } |
45 | diff --git a/src/storage/cached.rs b/src/storage/cached.rs |
46 | index f7c1a4d..168c309 100644 |
47 | --- a/src/storage/cached.rs |
48 | +++ b/src/storage/cached.rs |
49 | @@ -226,7 +226,7 @@ where |
50 | // Prometheus. |
51 | if self.lru.lock().await.get_refresh(key).is_some() { |
52 | // Cache hit! (Probably) |
53 | - let obj = self.cache.get(&key).await.map_err(Error::from_cache)?; |
54 | + let obj = self.cache.get(key).await.map_err(Error::from_cache)?; |
55 | |
56 | return match obj { |
57 | Some(obj) => Ok(Some(obj)), |
58 | @@ -235,12 +235,12 @@ where |
59 | // from our LRU. This can happen if the cache is cleared out |
60 | // manually. |
61 | let mut lru = self.lru.lock().await; |
62 | - lru.remove(&key); |
63 | + lru.remove(key); |
64 | |
65 | // Fall back to permanent storage. Note that this won't |
66 | // actually cache the object. This will be done next time |
67 | // the same object is requested. |
68 | - self.storage.get(&key).await.map_err(Error::from_storage) |
69 | + self.storage.get(key).await.map_err(Error::from_storage) |
70 | } |
71 | }; |
72 | } |
73 | diff --git a/src/storage/retrying.rs b/src/storage/retrying.rs |
74 | index 6d3032a..8e8d01b 100644 |
75 | --- a/src/storage/retrying.rs |
76 | +++ b/src/storage/retrying.rs |
77 | @@ -68,14 +68,14 @@ where |
78 | |
79 | async fn size(&self, key: &StorageKey) -> Result<Option<u64>, Self::Error> { |
80 | retry(ExponentialBackoff::default(), || async { |
81 | - Ok(self.storage.size(&key).await?) |
82 | + Ok(self.storage.size(key).await?) |
83 | }) |
84 | .await |
85 | } |
86 | |
87 | async fn delete(&self, key: &StorageKey) -> Result<(), Self::Error> { |
88 | retry(ExponentialBackoff::default(), || async { |
89 | - Ok(self.storage.delete(&key).await?) |
90 | + Ok(self.storage.delete(key).await?) |
91 | }) |
92 | .await |
93 | } |
94 | diff --git a/src/storage/s3.rs b/src/storage/s3.rs |
95 | index bae975b..cf02911 100644 |
96 | --- a/src/storage/s3.rs |
97 | +++ b/src/storage/s3.rs |
98 | @@ -435,11 +435,9 @@ where |
99 | } |
100 | |
101 | fn public_url(&self, key: &StorageKey) -> Option<String> { |
102 | - if let Some(cdn) = self.cdn.as_ref() { |
103 | - Some(format!("{}/{}", cdn, self.key_to_path(key))) |
104 | - } else { |
105 | - None |
106 | - } |
107 | + self.cdn |
108 | + .as_ref() |
109 | + .map(|cdn| format!("{}/{}", cdn, self.key_to_path(key))) |
110 | } |
111 | |
112 | async fn upload_url( |
113 | @@ -449,13 +447,11 @@ where |
114 | ) -> Option<String> { |
115 | // Don't use a presigned URL if we're not using a CDN. Otherwise, |
116 | // uploads will bypass the encryption process and fail to download. |
117 | - if self.cdn.is_none() { |
118 | - return None; |
119 | - } |
120 | + self.cdn.as_ref()?; |
121 | |
122 | let request = PutObjectRequest { |
123 | bucket: self.bucket.clone(), |
124 | - key: self.key_to_path(&key), |
125 | + key: self.key_to_path(key), |
126 | ..Default::default() |
127 | }; |
128 | let credentials = self.credential_provider.credentials().await.ok()?; |