fix: make count functions async to prevent frontend lock
This commit is contained in:
+12
-12
@@ -160,7 +160,7 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
pub async fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
||||||
let path = PathBuf::from(folder);
|
let path = PathBuf::from(folder);
|
||||||
let osu_user_config = get_osu_user_config(path.clone());
|
let osu_user_config = get_osu_user_config(path.clone());
|
||||||
let songs_path = osu_user_config
|
let songs_path = osu_user_config
|
||||||
@@ -173,12 +173,12 @@ pub fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
if let Ok(entries) = std::fs::read_dir(songs_folder) {
|
if let Ok(mut entries) = fs::read_dir(songs_folder).await {
|
||||||
for entry in entries.flatten() {
|
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||||
if entry.file_type().map_or(false, |ft| ft.is_dir()) {
|
if entry.file_type().await.map_or(false, |ft| ft.is_dir()) {
|
||||||
let dir_path = entry.path();
|
let dir_path = entry.path();
|
||||||
if let Ok(files) = std::fs::read_dir(&dir_path) {
|
if let Ok(mut files) = fs::read_dir(&dir_path).await {
|
||||||
for file in files.flatten() {
|
while let Ok(Some(file)) = files.next_entry().await {
|
||||||
if file.path().extension().map_or(false, |ext| ext == "osu") {
|
if file.path().extension().map_or(false, |ext| ext == "osu") {
|
||||||
count += 1;
|
count += 1;
|
||||||
break;
|
break;
|
||||||
@@ -192,7 +192,7 @@ pub fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_skins_count(folder: String) -> Option<u64> {
|
pub async fn get_skins_count(folder: String) -> Option<u64> {
|
||||||
let path = PathBuf::from(folder);
|
let path = PathBuf::from(folder);
|
||||||
let skins_folder = path.join("Skins");
|
let skins_folder = path.join("Skins");
|
||||||
|
|
||||||
@@ -201,12 +201,12 @@ pub fn get_skins_count(folder: String) -> Option<u64> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
if let Ok(entries) = std::fs::read_dir(skins_folder) {
|
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
||||||
for entry in entries.flatten() {
|
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||||
if entry.file_type().map_or(false, |ft| ft.is_dir()) {
|
if entry.file_type().await.map_or(false, |ft| ft.is_dir()) {
|
||||||
let dir_path = entry.path();
|
let dir_path = entry.path();
|
||||||
if let Ok(files) = std::fs::read_dir(&dir_path) {
|
if let Ok(mut files) = fs::read_dir(&dir_path).await {
|
||||||
for file in files.flatten() {
|
while let Ok(Some(file)) = files.next_entry().await {
|
||||||
if file.path().extension().map_or(false, |ext| ext == "ini") {
|
if file.path().extension().map_or(false, |ext| ext == "ini") {
|
||||||
count += 1;
|
count += 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user