fix: read beatmapset count from osu!.db instead of iterating songs folder

This commit is contained in:
2026-03-01 23:50:36 +01:00
parent f09405ed58
commit 24802b5132
3 changed files with 53 additions and 26 deletions
+44
View File
@@ -475,8 +475,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
dependencies = [
"iana-time-zone",
"js-sys",
"num-traits",
"serde",
"wasm-bindgen",
"windows-link 0.2.1",
]
@@ -995,6 +997,7 @@ dependencies = [
"md5",
"once_cell",
"open",
"osynic_osudb",
"reqwest",
"serde",
"serde_json",
@@ -2052,6 +2055,26 @@ dependencies = [
"winapi",
]
[[package]]
name = "liblzma"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6033b77c21d1f56deeae8014eb9fbe7bdf1765185a6c508b5ca82eeaed7f899"
dependencies = [
"liblzma-sys",
]
[[package]]
name = "liblzma-sys"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f2db66f3268487b5033077f266da6777d057949b8f93c8ad82e441df25e6186"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "libredox"
version = "0.1.12"
@@ -2262,6 +2285,15 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "nom"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
]
[[package]]
name = "ntapi"
version = "0.4.2"
@@ -2605,6 +2637,18 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "osynic_osudb"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d7f03567d97cdc0bf54380f0c525a00de1ce58ed9497f2409dfaf6112346b8a"
dependencies = [
"chrono",
"liblzma",
"nom",
"serde",
]
[[package]]
name = "pango"
version = "0.18.3"
+1
View File
@@ -35,6 +35,7 @@ open = "5.3.3"
discord-rich-presence = "1.1.0"
once_cell = "1.21.3"
futures-util = "0.3.32"
osynic_osudb = "0.1.4"
[target.'cfg(windows)'.dependencies]
winreg = "0.55.0"
+8 -26
View File
@@ -1,4 +1,5 @@
use hardware_id::get_id;
use osynic_osudb::entity::osu::osudb::OsuDB;
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
@@ -156,33 +157,14 @@ pub fn find_osu_installation() -> Option<String> {
#[tauri::command]
pub async fn get_beatmapsets_count(folder: String) -> Option<u64> {
let path = PathBuf::from(folder);
let osu_user_config = get_osu_user_config(path.clone());
let songs_path = osu_user_config
.and_then(|config| config.get("Songs").cloned())
.unwrap_or_else(|| path.join("Songs").to_string_lossy().into_owned());
let songs_folder = PathBuf::from(songs_path);
if !songs_folder.exists() {
return None;
let osu_db_path = path.join("osu!.db");
if !osu_db_path.exists() {
return Some(0);
}
let mut count = 0;
if let Ok(mut entries) = fs::read_dir(songs_folder).await {
while let Ok(Some(entry)) = entries.next_entry().await {
if entry.file_type().await.map_or(false, |ft| ft.is_dir()) {
let dir_path = entry.path();
if let Ok(mut files) = fs::read_dir(&dir_path).await {
while let Ok(Some(file)) = files.next_entry().await {
if file.path().extension().map_or(false, |ext| ext == "osu") {
count += 1;
break;
}
}
}
}
}
}
return Some(count);
let mut osudb = OsuDB::from_file(&osu_db_path).unwrap();
let beatmaps = osudb.beatmaps.iter_mut();
let beatmap_sets = beatmaps.map(|b| b.beatmapset_id).collect::<HashSet<_>>();
return Some(beatmap_sets.len() as u64);
}
#[derive(Serialize, Deserialize, Debug, Clone)]