mirror of
https://github.com/NetworkCats/rustyip.git
synced 2026-11-13 16:17:46 +00:00
refactor: use project-local data/ directory for MMDB in local dev
This commit is contained in:
+2
-2
@@ -1,8 +1,8 @@
|
||||
# Server listen address
|
||||
LISTEN_ADDR=0.0.0.0:3000
|
||||
|
||||
# Path to the MaxMind DB file
|
||||
DB_PATH=/data/Merged-IP.mmdb
|
||||
# Path to the MaxMind DB file (use data/Merged-IP.mmdb for local development)
|
||||
DB_PATH=data/Merged-IP.mmdb
|
||||
|
||||
# URL to download the MMDB database from
|
||||
DB_UPDATE_URL=https://github.com/NetworkCats/Merged-IP-Data/releases/latest/download/Merged-IP.mmdb
|
||||
|
||||
@@ -23,6 +23,7 @@ ehthumbs_vista.db
|
||||
|
||||
# Project
|
||||
*.mmdb
|
||||
data/
|
||||
.env
|
||||
haproxy/certs/
|
||||
|
||||
|
||||
@@ -8,16 +8,17 @@ use rustyip::db;
|
||||
use rustyip::handlers::AppState;
|
||||
use rustyip::routes::build_router;
|
||||
|
||||
fn test_db_path() -> &'static str {
|
||||
let path = "/tmp/Merged-IP.mmdb";
|
||||
if !Path::new(path).exists() {
|
||||
fn test_db_path() -> String {
|
||||
let manifest_dir = env!("CARGO_MANIFEST_DIR");
|
||||
let path = format!("{manifest_dir}/data/Merged-IP.mmdb");
|
||||
if !Path::new(&path).exists() {
|
||||
panic!("Test MMDB not found at {path}. Download it first.");
|
||||
}
|
||||
path
|
||||
}
|
||||
|
||||
fn build_test_app() -> axum::Router {
|
||||
let reader = db::load_db(Path::new(test_db_path())).expect("failed to load test DB");
|
||||
let reader = db::load_db(Path::new(&test_db_path())).expect("failed to load test DB");
|
||||
let shared_db = db::new_shared(reader);
|
||||
let state = AppState {
|
||||
db: shared_db,
|
||||
|
||||
Reference in New Issue
Block a user