diff options
author | iximeow <me@iximeow.net> | 2023-07-01 23:47:23 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2023-07-01 23:47:23 -0700 |
commit | f2366f4f95b0011aab517264e0ae84419abef660 (patch) | |
tree | f894e6ccd7a954aaafb876d545515faf537b5dc4 /src | |
parent | f9fd9d1ba1d2139699ca3e5125ac1913ac6234ae (diff) |
produce short sha after looking up the full sha so short urls do not panic from invalid bounds
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 1325d16..6f49cc8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -481,7 +481,6 @@ async fn handle_commit_status(Path(path): Path<(String, String, String)>, State( eprintln!("path: {}/{}, sha {}", path.0, path.1, path.2); let remote_path = format!("{}/{}", path.0, path.1); let sha = path.2; - let short_sha = &sha[0..9]; let (commit_id, sha): (u64, String) = if sha.len() >= 7 { match ctx.dbctx.conn.lock().unwrap() @@ -497,6 +496,8 @@ async fn handle_commit_status(Path(path): Path<(String, String, String)>, State( return (StatusCode::NOT_FOUND, Html("<html><body>no such commit</body></html>".to_string())); }; + let short_sha = &sha[0..9]; + let (remote_id, repo_id): (u64, u64) = ctx.dbctx.conn.lock().unwrap() .query_row("select id, repo_id from remotes where remote_path=?1;", [&remote_path], |row| Ok((row.get_unwrap(0), row.get_unwrap(1)))) .expect("can query"); |