server: fix downloaded repo version path

This commit is contained in:
nym21
2025-04-04 18:49:21 +02:00
parent 5f1a3a9c8f
commit 7d56d8e35b
4 changed files with 17 additions and 18 deletions

22
Cargo.lock generated
View File

@@ -641,9 +641,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.17"
version = "1.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
checksum = "525046617d8376e3db1deffb079e91cef90a89fc3ca5c185bbf8c9ecdd15cd5c"
dependencies = [
"jobserver",
"libc",
@@ -907,9 +907,9 @@ dependencies = [
[[package]]
name = "ctrlc"
version = "3.4.5"
version = "3.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3"
checksum = "697b5419f348fd5ae2478e8018cb016c00a5881c7f46c717de98ffd135a5651c"
dependencies = [
"nix",
"windows-sys 0.59.0",
@@ -1068,9 +1068,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
version = "0.3.10"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
dependencies = [
"libc",
"windows-sys 0.59.0",
@@ -1122,7 +1122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
dependencies = [
"crc32fast",
"miniz_oxide 0.8.5",
"miniz_oxide 0.8.7",
]
[[package]]
@@ -1663,9 +1663,9 @@ dependencies = [
[[package]]
name = "miniz_oxide"
version = "0.8.5"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
checksum = "ff70ce3e48ae43fa075863cef62e8b43b71a4f2382229920e0df362592919430"
dependencies = [
"adler2",
]
@@ -3522,9 +3522,9 @@ dependencies = [
[[package]]
name = "zip"
version = "2.5.0"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27c03817464f64e23f6f37574b4fdc8cf65925b5bfd2b0f2aedf959791941f88"
checksum = "febbe83a485467affa75a75d28dc7494acd2f819e549536c47d46b3089b56164"
dependencies = [
"aes",
"arbitrary",

View File

@@ -8,5 +8,5 @@ repository.workspace = true
[dependencies]
brk_logger = { workspace = true }
ctrlc = { version = "3.4.5", features = ["termination"] }
ctrlc = { version = "3.4.6", features = ["termination"] }
log = { workspace = true }

View File

@@ -25,6 +25,6 @@ oxc = { version = "0.62.0", features = ["codegen", "minifier"] }
serde = { workspace = true }
tokio = { version = "1.44.1", features = ["full"] }
tower-http = { version = "0.6.2", features = ["compression-full", "trace"] }
zip = "2.5.0"
zip = "2.6.0"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"

View File

@@ -49,6 +49,7 @@ pub struct AppState {
const DEV_PATH: &str = "../..";
const DOWNLOADS: &str = "downloads";
const WEBSITES: &str = "websites";
const VERSION: &str = env!("CARGO_PKG_VERSION");
pub struct Server(AppState);
@@ -66,16 +67,14 @@ impl Server {
} else {
let downloads_path = dot_brk_path().join(DOWNLOADS);
let version = format!("v{}", env!("CARGO_PKG_VERSION"));
let downloaded_websites_path = downloads_path.join(&version).join(WEBSITES);
let downloaded_websites_path = downloads_path.join(VERSION).join(WEBSITES);
if !fs::exists(&downloaded_websites_path)? {
info!("Downloading websites from Github...");
let url = format!(
"https://github.com/bitcoinresearchkit/brk/archive/refs/tags/{}.zip",
version
VERSION
);
let response = minreq::get(url).send()?;
@@ -150,7 +149,7 @@ impl Server {
let router = Router::new()
.add_api_routes()
.add_website_routes(state.website)
.route("/version", get(Json(env!("CARGO_PKG_VERSION"))))
.route("/version", get(Json(VERSION)))
.with_state(state)
.layer(compression_layer)
.layer(response_uri_layer)