mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-01-12 00:02:38 +08:00
Ship files for offline android/ios servers
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "assets"]
|
||||
path = assets
|
||||
url = https://git.ethanthesleepy.one/ethanaobrien/sif2-runtime-files
|
||||
20
Cargo.lock
generated
20
Cargo.lock
generated
@@ -642,6 +642,7 @@ dependencies = [
|
||||
"hex",
|
||||
"hmac",
|
||||
"include-flate-codegen",
|
||||
"include_dir",
|
||||
"jni",
|
||||
"json",
|
||||
"lazy_static",
|
||||
@@ -1021,6 +1022,25 @@ dependencies = [
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "include_dir"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd"
|
||||
dependencies = [
|
||||
"include_dir_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "include_dir_macros"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.12.1"
|
||||
|
||||
@@ -27,20 +27,21 @@ cbc = { version = "0.1.2", features = ["alloc"] }
|
||||
aes = "0.8.4"
|
||||
pem = "3.0.6"
|
||||
ureq = "3.1.4"
|
||||
include_dir = {version = "0.7.4", optional = true }
|
||||
|
||||
[target.aarch64-linux-android.dependencies]
|
||||
jni = { version = "0.21.1", features = ["invocation", "default"] }
|
||||
jni = { version = "0.21.1", features = ["invocation", "default"], optional = true }
|
||||
|
||||
[target.aarch64-apple-ios.dependencies]
|
||||
objc2 = "0.6.3"
|
||||
objc2-foundation = { version = "0.3.2", features = ["NSFileManager"] }
|
||||
objc2 = { version = "0.6.3", optional = true }
|
||||
objc2-foundation = { version = "0.3.2", features = ["NSFileManager"], optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
# To enable this library you MUST comment out lib block below and add --features library
|
||||
[features]
|
||||
library = []
|
||||
library = ["jni", "objc2", "objc2-foundation", "include_dir"]
|
||||
|
||||
#[lib]
|
||||
#crate-type = ["cdylib"]
|
||||
|
||||
1
assets
Submodule
1
assets
Submodule
Submodule assets added at dbb068e72c
@@ -26,7 +26,29 @@ async fn maintenance(_req: HttpRequest) -> HttpResponse {
|
||||
.body(r#"{"opened_at":"2024-02-05 02:00:00","closed_at":"2024-02-05 04:00:00","message":":(","server":1,"gamelib":0}"#)
|
||||
}
|
||||
|
||||
#[cfg(feature = "library")]
|
||||
use include_dir::{include_dir, Dir};
|
||||
|
||||
#[cfg(all(feature = "library", target_os = "ios"))]
|
||||
static SPART_FILES: Dir<'_> = include_dir!("assets/iOS/");
|
||||
|
||||
#[cfg(all(feature = "library", target_os = "android"))]
|
||||
static SPART_FILES: Dir<'_> = include_dir!("assets/Android/");
|
||||
|
||||
fn handle_assets(req: HttpRequest) -> HttpResponse {
|
||||
#[cfg(feature = "library")]
|
||||
{
|
||||
let lang: String = req.match_info().get("lang").unwrap_or("JP").parse().unwrap_or(String::from("JP"));
|
||||
let file_name: String = req.match_info().get("file").unwrap().parse().unwrap();
|
||||
let hash: String = req.match_info().get("file").unwrap().parse().unwrap();
|
||||
if let Some(file) = SPART_FILES.get_file(format!("{lang}/{hash}/{file_name}")) {
|
||||
let body = file.contents();
|
||||
return HttpResponse::Ok()
|
||||
.insert_header(ContentType(mime::APPLICATION_OCTET_STREAM))
|
||||
.insert_header(("content-length", body.len()))
|
||||
.body(body);
|
||||
}
|
||||
}
|
||||
let file_path = format!("assets{}", req.path());
|
||||
let exists = fs::exists(&file_path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user