Remove old asset lists / masterdata endpoints

This commit is contained in:
Ethan O'Brien
2026-07-26 23:28:05 -05:00
parent 2056511bd1
commit 6523ad4d4a
9 changed files with 2 additions and 100667 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ services:
#ENABLE_CUSTOM_SONGS: true # Custom songs are DISABLED by default; uncomment to enable upload/browse/download (webui + endpoints)
#PURGE: false # Purge dead user accounts on startup
#IMAGE_ASSET_PATH: /images/ # Images for cards in webui (will default to the public server)
#MASTERDATA: /masterdata/ # Override bundled asset lists / CSVs / new_user.json at runtime (missing files fall back to the internal copies)
#MASTERDATA: /masterdata/ # Override bundled CSVs / new_user.json at runtime (missing files fall back to the internal copies)
# Asset hash / version overrides. Leave unset to use the values bundled in
# the binary; set one to make the server report a different hash/version
+1 -1
View File
@@ -71,7 +71,7 @@ pub struct Args {
#[arg(long, default_value = "", help = "Path to image assets.")]
pub image_asset_path: String,
#[arg(long, default_value = "", help = "Optional directory to load asset lists and master data CSVs from at runtime. Layout mirrors the bundled assets (asset_lists/, csv/, csv-en/). Missing files fall back to the internal copies.")]
#[arg(long, default_value = "", help = "Optional directory to load master data CSVs from at runtime. Layout mirrors the bundled assets (csv/, csv-en/). Missing files fall back to the internal copies.")]
pub masterdata: String
}
-4
View File
@@ -28,8 +28,6 @@ pub mod items;
pub mod databases;
pub mod location;
pub mod event_ranking;
pub mod asset_lists;
mod master_data;
mod tools;
use actix_web::{
@@ -242,8 +240,6 @@ pub fn configure(cfg: &mut actix_web::web::ServiceConfig) {
cfg.configure(crate::static_handlers::routes);
cfg.service(
actix_web::web::scope("/api")
.configure(asset_lists::routes)
.configure(master_data::routes)
.service(
actix_web::web::scope("")
.wrap(from_fn(webui_fallback))
-54
View File
@@ -1,54 +0,0 @@
use actix_web::{HttpRequest, web, Responder, HttpResponse};
use actix_web::http::header::ContentType;
use jzon::object;
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::sync::Mutex;
use crate::include_file;
lazy_static! {
static ref LIST_CACHE: Mutex<HashMap<String, String>> = Mutex::new(HashMap::new());
}
pub fn routes(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/assetLists")
.route("/supported", web::get().to(supported))
.route("{platform}/{LANG}", web::get().to(get))
);
}
async fn get(_req: HttpRequest) -> impl Responder {
let mut response = object!{};
response["Bundle"] = load_list("Bundle").into();
response["Movie"] = load_list("Movie").into();
response["Sound"] = load_list("Sound").into();
let body = jzon::stringify(response);
HttpResponse::Ok()
.insert_header(("content-type", ContentType::json()))
.insert_header(("content-length", body.len()))
.body(body)
}
fn load_list(name: &str) -> String {
if let Some(cached) = LIST_CACHE.lock().unwrap().get(name) {
return cached.clone();
}
let rel = format!("asset_lists/{}.json", name);
let list = crate::runtime::read_masterdata_file(&rel)
.and_then(|b| String::from_utf8(b).ok())
.unwrap_or_else(|| match name {
"Bundle" => include_file!("src/router/asset_lists/Bundle.json"),
"Movie" => include_file!("src/router/asset_lists/Movie.json"),
"Sound" => include_file!("src/router/asset_lists/Sound.json"),
_ => unreachable!(),
});
LIST_CACHE.lock().unwrap().insert(name.to_string(), list.clone());
list
}
async fn supported() -> impl Responder {
"SUPPORTED"
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-21
View File
@@ -40,27 +40,6 @@ fn region_subdir(region: Region) -> &'static str {
}
}
pub fn get_all(region: Region) -> JsonValue {
let mut rv = object!{};
for file in dir_for(region).files() {
let table_name = file.path()
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or_default();
if table_name.is_empty() {
continue;
}
if let Some(bytes) = csv_bytes(region, table_name) {
rv[table_name] = String::from_utf8(bytes).unwrap_or_default().into();
}
}
rv
}
pub fn csv_bytes(region: Region, name: &str) -> Option<Vec<u8>> {
let rel = format!("{}/{}.csv", region_subdir(region), name);
if let Some(bytes) = crate::runtime::read_masterdata_file(&rel) {
-31
View File
@@ -1,31 +0,0 @@
use actix_web::{web, HttpRequest, HttpResponse, Responder};
use actix_web::http::header::ContentType;
use crate::router::databases::csv::{get_all, Region};
pub fn routes(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/masterdata")
.route("/supported", web::get().to(supported))
.route("/{platform}/{LANG}", web::get().to(mst))
);
}
async fn mst(req: HttpRequest) -> impl Responder {
let lang = req.match_info().get("LANG").unwrap_or("JP");
let region = match lang.to_ascii_uppercase().as_str() {
"JP" => Region::Jp,
_ => Region::En, // idk
};
let body = get_all(region);
let body = jzon::stringify(body);
HttpResponse::Ok()
.insert_header(("content-type", ContentType::json()))
.insert_header(("content-length", body.len()))
.body(body)
}
async fn supported() -> impl Responder {
"SUPPORTED"
}