@@ -8,7 +8,7 @@ use axum::{
8
8
} ;
9
9
use reqwest:: { get, StatusCode } ;
10
10
use serde:: Deserialize ;
11
- use serde_json:: Value ;
11
+ use serde_json:: { json , Value } ;
12
12
use std:: { fmt:: Display , fs:: create_dir_all, io:: Cursor , path:: Path as StdPath } ;
13
13
use tokio:: { fs:: File , io:: copy} ;
14
14
use tokio_util:: io:: ReaderStream ;
@@ -18,6 +18,7 @@ use common_utils::{read_json, write_json};
18
18
19
19
const BASE_PATH_CN : & str = "https://ak.hycdn.cn/assetbundle/official/Android/assets/" ;
20
20
const BASE_PATH_GL : & str = "https://ark-us-static-online.yo-star.com/assetbundle/official/Android/assets/" ;
21
+ const ASSETS_JSON : & str = "./assets/assets.json" ;
21
22
22
23
#[ derive( Deserialize ) ]
23
24
pub struct Asset {
@@ -61,6 +62,13 @@ pub async fn get_file(Path(asset): Path<Asset>) -> Response {
61
62
let path = format ! ( "./assets/{hash}/redirect/" ) ;
62
63
let config = read_json ( CONFIG_JSON_PATH ) ;
63
64
let mode = config[ "server" ] [ "mode" ] . as_str ( ) . unwrap ( ) ;
65
+ let mut assets_list = if !StdPath :: new ( ASSETS_JSON ) . exists ( ) {
66
+ json ! ( { hash: [ ] } )
67
+ } else {
68
+ read_json ( ASSETS_JSON )
69
+ } ;
70
+ assets_list[ hash] . as_array_mut ( ) . unwrap ( ) . push ( json ! ( name) ) ;
71
+ write_json ( ASSETS_JSON , & assets_list) ;
64
72
if config[ "assets" ] [ "downloadLocally" ] . as_bool ( ) . unwrap ( ) {
65
73
if !StdPath :: new ( & path) . exists ( ) {
66
74
create_dir_all ( & path) . unwrap ( ) ;
0 commit comments