mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
lint
This commit is contained in:
@@ -37,7 +37,7 @@ pub fn dir_delete(path: &str) {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn are_files_identical(path1: &str, path2: &str) -> bool {
|
pub fn are_files_identical(path1: &str, path2: &str) -> bool {
|
||||||
return diff(path1, path2);
|
diff(path1, path2)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -88,10 +88,12 @@ pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String)
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn delete_file(path: String) -> bool {
|
pub fn delete_file(path: String) -> bool {
|
||||||
match std::fs::remove_file(path) {
|
match std::fs::remove_file(path) {
|
||||||
Ok(_) => return true,
|
Ok(_) => true,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to delete file: {}", e);
|
println!("Failed to delete file: {}", e);
|
||||||
return false
|
false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
false
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,8 @@ pub fn patch_metadata(metadata_folder: &str) -> bool {
|
|||||||
};
|
};
|
||||||
|
|
||||||
file.write_all(&encrypted).unwrap();
|
file.write_all(&encrypted).unwrap();
|
||||||
return true;
|
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decrypt_metadata(file_path: &str) -> Vec<u8> {
|
fn decrypt_metadata(file_path: &str) -> Vec<u8> {
|
||||||
@@ -81,16 +82,18 @@ fn decrypt_metadata(file_path: &str) -> Vec<u8> {
|
|||||||
match dll_decrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
|
match dll_decrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Successfully decrypted global-metadata");
|
println!("Successfully decrypted global-metadata");
|
||||||
return data;
|
data
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to decrypt global-metadata: {}", e);
|
println!("Failed to decrypt global-metadata: {}", e);
|
||||||
return Vec::new();
|
Vec::new()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replace_keys(data: &Vec<u8>) -> Vec<u8> {
|
fn replace_keys(data: &[u8]) -> Vec<u8> {
|
||||||
let mut new_data = String::new();
|
let mut new_data = String::new();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -107,10 +110,10 @@ fn replace_keys(data: &Vec<u8>) -> Vec<u8> {
|
|||||||
|
|
||||||
if i == 2 {
|
if i == 2 {
|
||||||
println!("Replacing password key");
|
println!("Replacing password key");
|
||||||
new_data = replace_rsa_key(&data_str, &key, "passwordKey.txt");
|
new_data = replace_rsa_key(&data_str, key, "passwordKey.txt");
|
||||||
} else if i == 3 {
|
} else if i == 3 {
|
||||||
println!("Replacing dispatch key");
|
println!("Replacing dispatch key");
|
||||||
new_data = replace_rsa_key(&new_data, &key, "dispatchKey.txt");
|
new_data = replace_rsa_key(&new_data, key, "dispatchKey.txt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,22 +136,24 @@ fn replace_rsa_key(old_data: &str, to_replace: &str, file_name: &str) -> String
|
|||||||
let new_key = String::from_utf8_unchecked(key_data.to_vec());
|
let new_key = String::from_utf8_unchecked(key_data.to_vec());
|
||||||
|
|
||||||
// Replace old key with new key
|
// Replace old key with new key
|
||||||
return old_data.replace(to_replace, &new_key);
|
old_data.replace(to_replace, &new_key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encrypt_metadata(old_data: &Vec<u8>) -> Vec<u8> {
|
fn encrypt_metadata(old_data: &[u8]) -> Vec<u8> {
|
||||||
let mut data = old_data.to_vec();
|
let mut data = old_data.to_vec();
|
||||||
match dll_encrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
|
match dll_encrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Successfully encrypted global-metadata");
|
println!("Successfully encrypted global-metadata");
|
||||||
return data;
|
data
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to encrypt global-metadata: {}", e);
|
println!("Failed to encrypt global-metadata: {}", e);
|
||||||
return Vec::new();
|
Vec::new()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_vecs_match<T: PartialEq>(a: &Vec<T>, b: &Vec<T>) -> bool {
|
fn do_vecs_match<T: PartialEq>(a: &Vec<T>, b: &Vec<T>) -> bool {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { invoke } from '@tauri-apps/api'
|
import { invoke } from '@tauri-apps/api'
|
||||||
import { dataDir } from '@tauri-apps/api/path'
|
import { dataDir } from '@tauri-apps/api/path'
|
||||||
import { getConfig } from './configuration'
|
|
||||||
import DownloadHandler from './download'
|
import DownloadHandler from './download'
|
||||||
import { getGameExecutable, getGameFolder } from './game'
|
import { getGameExecutable, getGameFolder } from './game'
|
||||||
|
|
||||||
@@ -9,8 +8,6 @@ export async function patchMetadata() {
|
|||||||
path: await getGameMetadataPath() + '\\global-metadata.dat'
|
path: await getGameMetadataPath() + '\\global-metadata.dat'
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(await getGameMetadataPath())
|
|
||||||
|
|
||||||
if (!metadataExists) {
|
if (!metadataExists) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user