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

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)