mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-12 11:27:33 -05:00
cargo clippy
This commit is contained in:
parent
b21deaee5f
commit
2a4d927a41
11 changed files with 30 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM docker.io/library/debian:latest as builder
|
||||
FROM docker.io/library/debian:latest AS builder
|
||||
|
||||
# First - build
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ pub fn get_args() -> Args {
|
|||
pub fn get_data_path(file_name: &str) -> String {
|
||||
let args = get_args();
|
||||
let mut path = args.path;
|
||||
while path.ends_with("/") {
|
||||
while path.ends_with('/') {
|
||||
path.pop();
|
||||
}
|
||||
fs::create_dir_all(&path).unwrap();
|
||||
|
@ -209,5 +209,5 @@ async fn set_running(running: bool) {
|
|||
|
||||
async fn get_running() -> bool {
|
||||
let result = lock_onto_mutex!(RUNNING);
|
||||
return *result;
|
||||
*result
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ fn not_found(headers: &HeaderMap) -> HttpResponse {
|
|||
"server_time": global::timestamp(),
|
||||
"message": ""
|
||||
};
|
||||
return global::send(rv, 0, &headers)
|
||||
global::send(rv, 0, headers)
|
||||
}
|
||||
|
||||
async fn api_req(req: HttpRequest, body: String) -> HttpResponse {
|
||||
|
@ -171,11 +171,11 @@ pub async fn request(req: HttpRequest, body: String) -> HttpResponse {
|
|||
let args = crate::get_args();
|
||||
let headers = req.headers();
|
||||
if args.hidden && req.path().starts_with("/api/webui/") {
|
||||
return not_found(&headers);
|
||||
return not_found(headers);
|
||||
}
|
||||
if headers.get("aoharu-asset-version").is_none() && req.path().starts_with("/api") && !req.path().starts_with("/api/webui") {
|
||||
if args.hidden {
|
||||
return not_found(&headers);
|
||||
return not_found(headers);
|
||||
} else {
|
||||
return webui::main(req);
|
||||
}
|
||||
|
|
|
@ -35,16 +35,14 @@ fn do_reinforce(user: &mut JsonValue, body: &JsonValue, exp_id: &str, money_mult
|
|||
data["amount"] = (data["amount"].as_i64().unwrap() - money).into();
|
||||
}
|
||||
}
|
||||
if evolve {
|
||||
if !databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"].is_empty() {
|
||||
let chat = &databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"];
|
||||
let mission_id = databases::MISSION_REWARD[chat[0].to_string()]["value"].as_i64().unwrap();
|
||||
if evolve && !databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"].is_empty() {
|
||||
let chat = &databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"];
|
||||
let mission_id = databases::MISSION_REWARD[chat[0].to_string()]["value"].as_i64().unwrap();
|
||||
|
||||
if crate::router::chat::add_chat_from_chapter_id(mission_id, chats) {
|
||||
items::update_mission_status(chat[1].as_i64().unwrap(), 0, true, true, 1, missions);
|
||||
if !clear_mission_ids.contains(chat[1].as_i64().unwrap()) {
|
||||
clear_mission_ids.push(chat[1].clone()).unwrap();
|
||||
}
|
||||
if crate::router::chat::add_chat_from_chapter_id(mission_id, chats) {
|
||||
items::update_mission_status(chat[1].as_i64().unwrap(), 0, true, true, 1, missions);
|
||||
if !clear_mission_ids.contains(chat[1].as_i64().unwrap()) {
|
||||
clear_mission_ids.push(chat[1].clone()).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ async fn get_clearrate_json() -> JsonValue {
|
|||
let new = get_json();
|
||||
result.replace(new.clone());
|
||||
}
|
||||
return rv;
|
||||
rv
|
||||
}
|
||||
|
||||
pub async fn clearrate(_req: HttpRequest) -> Option<JsonValue> {
|
||||
|
|
|
@ -60,7 +60,7 @@ fn get_random_song() -> JsonValue {
|
|||
}
|
||||
|
||||
fn switch_music(event: &mut JsonValue, index: i32) {
|
||||
if index > 5 || index < 1 {
|
||||
if !(1..=5).contains(&index) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,5 +109,5 @@ pub async fn get_scores_json() -> JsonValue {
|
|||
let new = get_json();
|
||||
result.replace(new.clone());
|
||||
}
|
||||
return rv;
|
||||
rv
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ pub fn get_asset_hash(asset_version: String, android: bool) -> String {
|
|||
} else {
|
||||
ASSET_HASH_ANDROID_JP.to_string()
|
||||
}
|
||||
} else if args.jp_ios_asset_hash != String::new() {
|
||||
args.jp_ios_asset_hash
|
||||
} else {
|
||||
if args.jp_ios_asset_hash != String::new() {
|
||||
args.jp_ios_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_IOS_JP.to_string()
|
||||
}
|
||||
ASSET_HASH_IOS_JP.to_string()
|
||||
}
|
||||
} else if android {
|
||||
if args.en_android_asset_hash != String::new() {
|
||||
|
@ -40,12 +38,10 @@ pub fn get_asset_hash(asset_version: String, android: bool) -> String {
|
|||
} else {
|
||||
ASSET_HASH_ANDROID.to_string()
|
||||
}
|
||||
} else if args.en_ios_asset_hash != String::new() {
|
||||
args.en_ios_asset_hash
|
||||
} else {
|
||||
if args.en_ios_asset_hash != String::new() {
|
||||
args.en_ios_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_IOS.to_string()
|
||||
}
|
||||
ASSET_HASH_IOS.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ pub fn migration_password_register(req: HttpRequest, body: String) -> HttpRespon
|
|||
|
||||
pub fn get_protocol() -> String {
|
||||
let args = crate::get_args();
|
||||
if args.https == true {
|
||||
if args.https {
|
||||
return String::from("https");
|
||||
}
|
||||
String::from("http")
|
||||
|
|
|
@ -325,7 +325,7 @@ async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
|||
let args = crate::get_args();
|
||||
|
||||
let mut host = args.npps4;
|
||||
while host.ends_with("/") {
|
||||
while host.ends_with('/') {
|
||||
host.pop();
|
||||
}
|
||||
let url = format!("{}/ewexport?sha1={}", host, sha_id);
|
||||
|
@ -334,7 +334,7 @@ async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
|||
let client = reqwest::Client::new();
|
||||
let response = client.get(url);
|
||||
let response_body = response.send().await.ok()?.text().await.ok()?;
|
||||
Some(json::parse(&response_body).ok()?)
|
||||
json::parse(&response_body).ok()
|
||||
}
|
||||
|
||||
fn clean_sif_data(current: &JsonValue) -> JsonValue {
|
||||
|
|
10
src/sql.rs
10
src/sql.rs
|
@ -41,12 +41,12 @@ impl SQLite {
|
|||
pub fn lock_and_select(&self, command: &str, args: &[&dyn ToSql]) -> Result<String, rusqlite::Error> {
|
||||
let conn = lock_onto_mutex!(self.engine);
|
||||
let mut stmt = conn.prepare(command)?;
|
||||
return stmt.query_row(args, |row| {
|
||||
stmt.query_row(args, |row| {
|
||||
match row.get::<usize, i64>(0) {
|
||||
Ok(val) => Ok(val.to_string()),
|
||||
Err(_) => row.get(0)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
pub fn lock_and_select_all(&self, command: &str, args: &[&dyn ToSql]) -> Result<JsonValue, rusqlite::Error> {
|
||||
let conn = lock_onto_mutex!(self.engine);
|
||||
|
@ -65,12 +65,12 @@ impl SQLite {
|
|||
Err(_) => rv.push(res).unwrap()
|
||||
};
|
||||
}
|
||||
return Ok(rv);
|
||||
Ok(rv)
|
||||
}
|
||||
pub fn get_live_data(&self, id: i64) -> Result<Live, rusqlite::Error> {
|
||||
let conn = lock_onto_mutex!(self.engine);
|
||||
let mut stmt = conn.prepare("SELECT * FROM lives WHERE live_id=?1")?;
|
||||
return stmt.query_row(params!(id), |row| {
|
||||
stmt.query_row(params!(id), |row| {
|
||||
Ok(Live {
|
||||
live_id: row.get(0)?,
|
||||
normal_failed: row.get(1)?,
|
||||
|
@ -82,7 +82,7 @@ impl SQLite {
|
|||
master_failed: row.get(7)?,
|
||||
master_pass: row.get(8)?,
|
||||
})
|
||||
});
|
||||
})
|
||||
}
|
||||
pub fn create_store_v2(&self, table: &str) {
|
||||
self.lock_and_exec(table, params!());
|
||||
|
|
Loading…
Add table
Reference in a new issue