From 9d86d9c9ffa6245af9ab8aacafa173dacc016323 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 15 Jul 2022 21:27:50 -0700 Subject: [PATCH] lint --- src-tauri/src/file_helpers.rs | 8 +++++--- src-tauri/src/metadata_patcher.rs | 25 +++++++++++++++---------- src/utils/metadata.ts | 3 --- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src-tauri/src/file_helpers.rs b/src-tauri/src/file_helpers.rs index b70b196..4ace001 100644 --- a/src-tauri/src/file_helpers.rs +++ b/src-tauri/src/file_helpers.rs @@ -37,7 +37,7 @@ pub fn dir_delete(path: &str) { #[tauri::command] pub fn are_files_identical(path1: &str, path2: &str) -> bool { - return diff(path1, path2); + diff(path1, path2) } #[tauri::command] @@ -88,10 +88,12 @@ pub fn copy_file_with_new_name(path: String, new_path: String, new_name: String) #[tauri::command] pub fn delete_file(path: String) -> bool { match std::fs::remove_file(path) { - Ok(_) => return true, + Ok(_) => true, Err(e) => { println!("Failed to delete file: {}", e); - return false + false } }; + + false } \ No newline at end of file diff --git a/src-tauri/src/metadata_patcher.rs b/src-tauri/src/metadata_patcher.rs index 2c7a93a..bc6a83b 100644 --- a/src-tauri/src/metadata_patcher.rs +++ b/src-tauri/src/metadata_patcher.rs @@ -55,7 +55,8 @@ pub fn patch_metadata(metadata_folder: &str) -> bool { }; file.write_all(&encrypted).unwrap(); - return true; + + true } fn decrypt_metadata(file_path: &str) -> Vec { @@ -81,16 +82,18 @@ fn decrypt_metadata(file_path: &str) -> Vec { match dll_decrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) { Ok(_) => { println!("Successfully decrypted global-metadata"); - return data; + data } Err(e) => { println!("Failed to decrypt global-metadata: {}", e); - return Vec::new(); + Vec::new() } }; + + Vec::new() } -fn replace_keys(data: &Vec) -> Vec { +fn replace_keys(data: &[u8]) -> Vec { let mut new_data = String::new(); unsafe { @@ -107,10 +110,10 @@ fn replace_keys(data: &Vec) -> Vec { if i == 2 { 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 { 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()); // 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) -> Vec { +fn encrypt_metadata(old_data: &[u8]) -> Vec { let mut data = old_data.to_vec(); match dll_encrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) { Ok(_) => { println!("Successfully encrypted global-metadata"); - return data; + data } Err(e) => { println!("Failed to encrypt global-metadata: {}", e); - return Vec::new(); + Vec::new() } }; + + Vec::new() } fn do_vecs_match(a: &Vec, b: &Vec) -> bool { diff --git a/src/utils/metadata.ts b/src/utils/metadata.ts index 7a8eb26..2768812 100644 --- a/src/utils/metadata.ts +++ b/src/utils/metadata.ts @@ -1,6 +1,5 @@ import { invoke } from '@tauri-apps/api' import { dataDir } from '@tauri-apps/api/path' -import { getConfig } from './configuration' import DownloadHandler from './download' import { getGameExecutable, getGameFolder } from './game' @@ -9,8 +8,6 @@ export async function patchMetadata() { path: await getGameMetadataPath() + '\\global-metadata.dat' }) - console.log(await getGameMetadataPath()) - if (!metadataExists) { return false }