mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
codefix
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
use std::process::exit;
|
||||
use std::process::Command;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn reopen_as_admin() {
|
||||
let install = std::env::current_exe().unwrap();
|
||||
|
||||
@@ -17,9 +17,9 @@ pub fn rename(path: String, new_name: String) {
|
||||
new_path = path.replace('\\', "/");
|
||||
}
|
||||
|
||||
let path_replaced = &path.replace(&new_path.split('/').last().unwrap(), &new_name);
|
||||
let path_replaced = &path.replace(new_path.split('/').last().unwrap(), &new_name);
|
||||
|
||||
match fs::rename(&path, &path_replaced) {
|
||||
match fs::rename(&path, path_replaced) {
|
||||
Ok(_) => {
|
||||
println!("Renamed {} to {}", &path, path_replaced);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ pub fn copy_file(path: String, new_path: String) -> bool {
|
||||
}
|
||||
|
||||
// Copy old to new
|
||||
match std::fs::copy(&path_buf, format!("{}/{}", new_path, filename)) {
|
||||
match std::fs::copy(path_buf, format!("{}/{}", new_path, filename)) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
println!("Failed to copy file: {}", e);
|
||||
@@ -98,7 +98,7 @@ pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String)
|
||||
new_path_buf.push(new_name);
|
||||
|
||||
// Copy old to new
|
||||
match std::fs::copy(&path_buf, &new_path_buf) {
|
||||
match std::fs::copy(path_buf, &new_path_buf) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
println!("Failed to copy file: {}", e);
|
||||
@@ -152,7 +152,7 @@ pub fn write_file(path: String, contents: String) {
|
||||
let path_buf = PathBuf::from(&path);
|
||||
|
||||
// Create file if it exists, otherwise just open and rewrite
|
||||
let mut file = match fs::File::create(&path_buf) {
|
||||
let mut file = match fs::File::create(path_buf) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
println!("Failed to open file: {}", e);
|
||||
|
||||
@@ -9,7 +9,7 @@ pub async fn get_lang(window: tauri::Window, lang: String) -> String {
|
||||
let lang_path: PathBuf = [&install_location(), "lang", &format!("{}.json", lang)]
|
||||
.iter()
|
||||
.collect();
|
||||
match std::fs::read_to_string(&lang_path) {
|
||||
match std::fs::read_to_string(lang_path) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
emit_lang_err(window, format!("Failed to read language file: {}", e));
|
||||
|
||||
@@ -60,7 +60,7 @@ fn main() {
|
||||
|
||||
// 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()) {
|
||||
fs::create_dir_all(&data_dir().unwrap().join("cultivation")).unwrap();
|
||||
fs::create_dir_all(data_dir().unwrap().join("cultivation")).unwrap();
|
||||
}
|
||||
|
||||
// Always set CWD to the location of the executable.
|
||||
|
||||
@@ -353,7 +353,7 @@ pub fn install_ca_files(cert_path: &Path) {
|
||||
// Create dir if it doesn't exist
|
||||
fs::create_dir_all(&usr_certs).expect("Unable to create local certificate directory");
|
||||
|
||||
fs::copy(cert_path, &usr_cert_path).expect("Unable to copy cert to local certificate directory");
|
||||
fs::copy(cert_path, usr_cert_path).expect("Unable to copy cert to local certificate directory");
|
||||
run_command("update-ca-certificates", vec![], None);
|
||||
|
||||
println!("Installed certificate.");
|
||||
|
||||
@@ -27,7 +27,7 @@ pub fn run_program_relative(path: String, args: Option<String>) {
|
||||
open::that(format!("{} {}", &path, args.unwrap_or_else(|| "".into()))).unwrap_or(());
|
||||
|
||||
// Restore the original working directory
|
||||
std::env::set_current_dir(&cwd).unwrap();
|
||||
std::env::set_current_dir(cwd).unwrap();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -52,7 +52,7 @@ pub fn run_command(program: &str, args: Vec<&str>, relative: Option<bool>) {
|
||||
cmd(prog, args).run().unwrap();
|
||||
|
||||
// Restore the original working directory
|
||||
std::env::set_current_dir(&cwd).unwrap();
|
||||
std::env::set_current_dir(cwd).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ pub(crate) async fn query(site: &str) -> String {
|
||||
.ok();
|
||||
|
||||
if response.is_some() {
|
||||
return response.unwrap().text().await.unwrap();
|
||||
response.unwrap().text().await.unwrap()
|
||||
} else {
|
||||
false.to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user