diff options
| author | Rutger Broekhoff | 2026-02-20 19:04:13 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-02-20 19:04:20 +0100 |
| commit | fd69069e3143d895a51c0621a134b334fc24b762 (patch) | |
| tree | 01bd5f3f96574d6b5543c26f1b9820034cc364c0 | |
| parent | a208bdb9d6db274afaebf8c1676ee8792b9ed7d4 (diff) | |
| download | gitolfs3-fd69069e3143d895a51c0621a134b334fc24b762.tar.gz gitolfs3-fd69069e3143d895a51c0621a134b334fc24b762.zip | |
| -rw-r--r-- | gitolfs3-authenticate/src/main.rs | 4 | ||||
| -rw-r--r-- | gitolfs3-server/src/api.rs | 9 | ||||
| -rw-r--r-- | gitolfs3-server/src/handler.rs | 8 |
3 files changed, 8 insertions, 13 deletions
diff --git a/gitolfs3-authenticate/src/main.rs b/gitolfs3-authenticate/src/main.rs index 1195b1c..bd44394 100644 --- a/gitolfs3-authenticate/src/main.rs +++ b/gitolfs3-authenticate/src/main.rs | |||
| @@ -49,9 +49,9 @@ fn main() -> ExitCode { | |||
| 49 | ), | 49 | ), |
| 50 | }, | 50 | }, |
| 51 | "expires_at": expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true), | 51 | "expires_at": expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true), |
| 52 | "href": format!("{}{}/info/lfs", config.href_base, repo_name), | 52 | "href": format!("{}{repo_name}/info/lfs", config.href_base), |
| 53 | }); | 53 | }); |
| 54 | println!("{}", response); | 54 | println!("{response}"); |
| 55 | 55 | ||
| 56 | ExitCode::SUCCESS | 56 | ExitCode::SUCCESS |
| 57 | } | 57 | } |
diff --git a/gitolfs3-server/src/api.rs b/gitolfs3-server/src/api.rs index 72ef8c6..b80c83a 100644 --- a/gitolfs3-server/src/api.rs +++ b/gitolfs3-server/src/api.rs | |||
| @@ -168,20 +168,15 @@ fn default_transfers() -> Vec<TransferAdapter> { | |||
| 168 | vec![TransferAdapter::Basic] | 168 | vec![TransferAdapter::Basic] |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy)] | 171 | #[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy)] |
| 172 | pub enum HashAlgo { | 172 | pub enum HashAlgo { |
| 173 | #[default] | ||
| 173 | #[serde(rename = "sha256")] | 174 | #[serde(rename = "sha256")] |
| 174 | Sha256, | 175 | Sha256, |
| 175 | #[serde(other)] | 176 | #[serde(other)] |
| 176 | Unknown, | 177 | Unknown, |
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | impl Default for HashAlgo { | ||
| 180 | fn default() -> Self { | ||
| 181 | Self::Sha256 | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | #[derive(Debug, Serialize, Clone)] | 180 | #[derive(Debug, Serialize, Clone)] |
| 186 | pub struct BatchResponse { | 181 | pub struct BatchResponse { |
| 187 | pub transfer: TransferAdapter, | 182 | pub transfer: TransferAdapter, |
diff --git a/gitolfs3-server/src/handler.rs b/gitolfs3-server/src/handler.rs index ee52a31..1f47c9e 100644 --- a/gitolfs3-server/src/handler.rs +++ b/gitolfs3-server/src/handler.rs | |||
| @@ -88,7 +88,7 @@ async fn handle_download_object( | |||
| 88 | trusted: bool, | 88 | trusted: bool, |
| 89 | ) -> BatchResponseObject { | 89 | ) -> BatchResponseObject { |
| 90 | let (oid0, oid1) = (HexByte(obj.oid[0]), HexByte(obj.oid[1])); | 90 | let (oid0, oid1) = (HexByte(obj.oid[0]), HexByte(obj.oid[1])); |
| 91 | let full_path = format!("{repo}/lfs/objects/{}/{}/{}", oid0, oid1, obj.oid); | 91 | let full_path = format!("{repo}/lfs/objects/{oid0}/{oid1}/{}", obj.oid); |
| 92 | 92 | ||
| 93 | let content_length = match state.check_object(repo, obj).await { | 93 | let content_length = match state.check_object(repo, obj).await { |
| 94 | Ok(ObjectStatus::ExistsOk { content_length }) => content_length, | 94 | Ok(ObjectStatus::ExistsOk { content_length }) => content_length, |
| @@ -267,7 +267,7 @@ pub async fn handle_obj_download( | |||
| 267 | return e.into_response(); | 267 | return e.into_response(); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | let full_path = format!("{repo}/lfs/objects/{}/{}/{}", oid0, oid1, oid); | 270 | let full_path = format!("{repo}/lfs/objects/{oid0}/{oid1}/{oid}"); |
| 271 | let result = match state | 271 | let result = match state |
| 272 | .s3_client | 272 | .s3_client |
| 273 | .get_object() | 273 | .get_object() |
| @@ -285,7 +285,7 @@ pub async fn handle_obj_download( | |||
| 285 | "Failed to query object information", | 285 | "Failed to query object information", |
| 286 | ) | 286 | ) |
| 287 | .into_response(); | 287 | .into_response(); |
| 288 | }, | 288 | } |
| 289 | Err(e) => { | 289 | Err(e) => { |
| 290 | println!("Failed to GetObject (repo {repo}, OID {oid}): {e}"); | 290 | println!("Failed to GetObject (repo {repo}, OID {oid}): {e}"); |
| 291 | return ( | 291 | return ( |
| @@ -324,7 +324,7 @@ async fn handle_upload_object( | |||
| 324 | obj: &BatchRequestObject, | 324 | obj: &BatchRequestObject, |
| 325 | ) -> Option<BatchResponseObject> { | 325 | ) -> Option<BatchResponseObject> { |
| 326 | let (oid0, oid1) = (HexByte(obj.oid[0]), HexByte(obj.oid[1])); | 326 | let (oid0, oid1) = (HexByte(obj.oid[0]), HexByte(obj.oid[1])); |
| 327 | let full_path = format!("{repo}/lfs/objects/{}/{}/{}", oid0, oid1, obj.oid); | 327 | let full_path = format!("{repo}/lfs/objects/{oid0}/{oid1}/{}", obj.oid); |
| 328 | 328 | ||
| 329 | match state.check_object(repo, obj).await { | 329 | match state.check_object(repo, obj).await { |
| 330 | Ok(ObjectStatus::ExistsOk { .. }) => { | 330 | Ok(ObjectStatus::ExistsOk { .. }) => { |