mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 08:04:52 +01:00
lint fixes
This commit is contained in:
@@ -33,11 +33,11 @@ fn try_flush() {
|
|||||||
std::io::stdout().flush().unwrap_or(())
|
std::io::stdout().flush().unwrap_or(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_arg(args: &Vec<String>, arg: &str) -> bool {
|
fn has_arg(args: &[String], arg: &str) -> bool {
|
||||||
args.contains(&arg.to_string())
|
args.contains(&arg.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn arg_handler(args: &Vec<String>) {
|
async fn arg_handler(args: &[String]) {
|
||||||
if has_arg(args, "--proxy") {
|
if has_arg(args, "--proxy") {
|
||||||
let mut pathbuf = tauri::api::path::data_dir().unwrap();
|
let mut pathbuf = tauri::api::path::data_dir().unwrap();
|
||||||
pathbuf.push("cultivation");
|
pathbuf.push("cultivation");
|
||||||
@@ -55,7 +55,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup datadir/cultivation just in case something went funky and it wasn't made
|
// Setup datadir/cultivation just in case something went funky and it wasn't made
|
||||||
if !dir_exists(&data_dir().unwrap().join("cultivation").to_str().unwrap()) {
|
if !dir_exists(data_dir().unwrap().join("cultivation").to_str().unwrap()) {
|
||||||
fs::create_dir_all(&data_dir().unwrap().join("cultivation")).unwrap();
|
fs::create_dir_all(&data_dir().unwrap().join("cultivation")).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* https://github.com/omjadas/hudsucker/blob/main/examples/log.rs
|
* https://github.com/omjadas/hudsucker/blob/main/examples/log.rs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::system_helpers::run_command;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::{path::PathBuf, str::FromStr, sync::Mutex};
|
use std::{path::PathBuf, str::FromStr, sync::Mutex};
|
||||||
|
|
||||||
@@ -180,7 +179,7 @@ pub fn connect_to_proxy(proxy_port: u16) {
|
|||||||
fs::write("/etc/environment", env_file).unwrap();
|
fs::write("/etc/environment", env_file).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(macos)]
|
#[cfg(target_od = "macos")]
|
||||||
pub fn connect_to_proxy(_proxy_port: u16) {
|
pub fn connect_to_proxy(_proxy_port: u16) {
|
||||||
println!("No Mac support yet. Someone mail me a Macbook and I will do it B)")
|
println!("No Mac support yet. Someone mail me a Macbook and I will do it B)")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use registry::{Data, Hive, Security};
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_program(path: String, args: Option<String>) {
|
pub fn run_program(path: String, args: Option<String>) {
|
||||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
open::that(format!("{} {}", &path, &args.unwrap_or("".into()))).unwrap_or(());
|
open::that(format!("{} {}", &path, &args.unwrap_or_else(|| "".into()))).unwrap_or(());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -24,7 +24,7 @@ pub fn run_program_relative(path: String, args: Option<String>) {
|
|||||||
std::env::set_current_dir(&path_buf).unwrap();
|
std::env::set_current_dir(&path_buf).unwrap();
|
||||||
|
|
||||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
open::that(format!("{} {}", &path, args.unwrap_or("".into()))).unwrap_or(());
|
open::that(format!("{} {}", &path, args.unwrap_or_else(|| "".into()))).unwrap_or(());
|
||||||
|
|
||||||
// Restore the original working directory
|
// Restore the original working directory
|
||||||
std::env::set_current_dir(&cwd).unwrap();
|
std::env::set_current_dir(&cwd).unwrap();
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ pub fn unzip(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
full_path = new_path.clone();
|
full_path = new_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Is rar file? {}", zipfile.ends_with(".rar"));
|
println!("Is rar file? {}", zipfile.ends_with(".rar"));
|
||||||
@@ -78,7 +78,7 @@ pub fn unzip(
|
|||||||
// Get the name of the inenr file in the zip file
|
// Get the name of the inenr file in the zip file
|
||||||
let mut zip = zip::ZipArchive::new(&f).unwrap();
|
let mut zip = zip::ZipArchive::new(&f).unwrap();
|
||||||
let file = zip.by_index(0).unwrap();
|
let file = zip.by_index(0).unwrap();
|
||||||
name = file.name().to_string().clone();
|
name = file.name().to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
@@ -111,23 +111,21 @@ pub fn unzip(
|
|||||||
for entry in read_dir(&write_path).unwrap() {
|
for entry in read_dir(&write_path).unwrap() {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
let entry_path = entry.path();
|
let entry_path = entry.path();
|
||||||
if entry_path.is_dir() {
|
if entry_path.is_dir() && !dirs.contains(&entry_path) {
|
||||||
if !dirs.contains(&entry_path) {
|
new_dir = entry_path.to_str().unwrap().to_string();
|
||||||
new_dir = entry_path.to_str().unwrap().to_string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut res_hash = std::collections::HashMap::new();
|
let mut res_hash = std::collections::HashMap::new();
|
||||||
res_hash.insert("file", zipfile.to_string());
|
res_hash.insert("file", zipfile.to_string());
|
||||||
res_hash.insert("new_folder", new_dir.to_string());
|
res_hash.insert("new_folder", new_dir);
|
||||||
|
|
||||||
window.emit("extract_end", &res_hash).unwrap();
|
window.emit("extract_end", &res_hash).unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_rar(rarfile: &String, _f: &File, full_path: &path::PathBuf, _top_level: bool) -> bool {
|
fn extract_rar(rarfile: &str, _f: &File, full_path: &path::Path, _top_level: bool) -> bool {
|
||||||
let archive = Archive::new(rarfile.clone());
|
let archive = Archive::new(rarfile.to_string());
|
||||||
|
|
||||||
let mut open_archive = archive
|
let mut open_archive = archive
|
||||||
.extract_to(full_path.to_str().unwrap().to_string())
|
.extract_to(full_path.to_str().unwrap().to_string())
|
||||||
@@ -149,7 +147,7 @@ fn extract_rar(rarfile: &String, _f: &File, full_path: &path::PathBuf, _top_leve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_zip(_zipfile: &String, f: &File, full_path: &path::PathBuf, top_level: bool) -> bool {
|
fn extract_zip(_zipfile: &str, f: &File, full_path: &path::Path, top_level: bool) -> bool {
|
||||||
match zip_extract::extract(f, full_path, top_level) {
|
match zip_extract::extract(f, full_path, top_level) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!(
|
println!(
|
||||||
|
|||||||
Reference in New Issue
Block a user