diff options
Diffstat (limited to 'gitolfs3-server/src/handler.rs')
-rw-r--r-- | gitolfs3-server/src/handler.rs | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/gitolfs3-server/src/handler.rs b/gitolfs3-server/src/handler.rs index be39721..c5d4a61 100644 --- a/gitolfs3-server/src/handler.rs +++ b/gitolfs3-server/src/handler.rs | |||
@@ -144,31 +144,31 @@ async fn handle_download_object( | |||
144 | }; | 144 | }; |
145 | } | 145 | } |
146 | 146 | ||
147 | if let Some(content_length) = content_length { | 147 | if let Some(content_length) = content_length |
148 | if content_length > 0 { | 148 | && content_length > 0 |
149 | match state | 149 | { |
150 | .dl_limiter | 150 | match state |
151 | .lock() | 151 | .dl_limiter |
152 | .await | 152 | .lock() |
153 | .request(content_length as u64) | 153 | .await |
154 | .await | 154 | .request(content_length as u64) |
155 | { | 155 | .await |
156 | Ok(true) => {} | 156 | { |
157 | Ok(false) => { | 157 | Ok(true) => {} |
158 | return BatchResponseObject::error( | 158 | Ok(false) => { |
159 | obj, | 159 | return BatchResponseObject::error( |
160 | http::StatusCode::SERVICE_UNAVAILABLE, | 160 | obj, |
161 | "Public LFS downloads temporarily unavailable".to_string(), | 161 | http::StatusCode::SERVICE_UNAVAILABLE, |
162 | ); | 162 | "Public LFS downloads temporarily unavailable".to_string(), |
163 | } | 163 | ); |
164 | Err(e) => { | 164 | } |
165 | println!("Failed to request {content_length} bytes from download limiter: {e}"); | 165 | Err(e) => { |
166 | return BatchResponseObject::error( | 166 | println!("Failed to request {content_length} bytes from download limiter: {e}"); |
167 | obj, | 167 | return BatchResponseObject::error( |
168 | http::StatusCode::INTERNAL_SERVER_ERROR, | 168 | obj, |
169 | "Internal server error".to_string(), | 169 | http::StatusCode::INTERNAL_SERVER_ERROR, |
170 | ); | 170 | "Internal server error".to_string(), |
171 | } | 171 | ); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
@@ -433,12 +433,11 @@ fn s3_encode_checksum(oid: Oid) -> String { | |||
433 | } | 433 | } |
434 | 434 | ||
435 | fn s3_validate_checksum(oid: Oid, obj: &HeadObjectOutput) -> bool { | 435 | fn s3_validate_checksum(oid: Oid, obj: &HeadObjectOutput) -> bool { |
436 | if let Some(checksum) = obj.checksum_sha256() { | 436 | if let Some(checksum) = obj.checksum_sha256() |
437 | if let Ok(checksum) = BASE64_STANDARD.decode(checksum) { | 437 | && let Ok(checksum) = BASE64_STANDARD.decode(checksum) |
438 | if let Ok(checksum32b) = TryInto::<[u8; 32]>::try_into(checksum) { | 438 | && let Ok(checksum32b) = TryInto::<[u8; 32]>::try_into(checksum) |
439 | return Oid::from(checksum32b) == oid; | 439 | { |
440 | } | 440 | return Oid::from(checksum32b) == oid; |
441 | } | ||
442 | } | 441 | } |
443 | true | 442 | true |
444 | } | 443 | } |