fix: unsafe use
This commit is contained in:
1 file changed
+31
-13
+31
-13
@@ -265,8 +265,7 @@ pub async fn read_file_chunk(path: String, offset: u64, length: u64) -> Result<V
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_hwid() -> String {
|
pub fn get_hwid() -> String {
|
||||||
get_id()
|
get_id().unwrap_or("recorderinsandybridge".to_string())
|
||||||
.unwrap_or("recorderinsandybridge".to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Show the native macOS picker, which can select `osu!.app` bundles as files.
|
/// Show the native macOS picker, which can select `osu!.app` bundles as files.
|
||||||
@@ -551,7 +550,8 @@ pub async fn get_skins_count(folder: String) -> Option<u64> {
|
|||||||
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
||||||
while let Ok(Some(entry)) = entries.next_entry().await {
|
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||||
if let Ok(ft) = entry.file_type().await
|
if let Ok(ft) = entry.file_type().await
|
||||||
&& ft.is_dir() {
|
&& ft.is_dir()
|
||||||
|
{
|
||||||
let dir_path = entry.path();
|
let dir_path = entry.path();
|
||||||
let has_ini = tokio::fs::try_exists(dir_path.join("skin.ini"))
|
let has_ini = tokio::fs::try_exists(dir_path.join("skin.ini"))
|
||||||
.await
|
.await
|
||||||
@@ -759,7 +759,7 @@ pub async fn run_osu(
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if optimize {
|
if optimize {
|
||||||
#[link(name = "winmm")]
|
#[link(name = "winmm")]
|
||||||
extern "system" {
|
unsafe extern "system" {
|
||||||
fn timeBeginPeriod(uPeriod: u32) -> u32;
|
fn timeBeginPeriod(uPeriod: u32) -> u32;
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -906,7 +906,7 @@ pub async fn run_osu(
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if optimize {
|
if optimize {
|
||||||
#[link(name = "winmm")]
|
#[link(name = "winmm")]
|
||||||
extern "system" {
|
unsafe extern "system" {
|
||||||
fn timeEndPeriod(uPeriod: u32) -> u32;
|
fn timeEndPeriod(uPeriod: u32) -> u32;
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1062,7 +1062,10 @@ pub async fn download_ezpp_launcher_update_files(
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let patcher_exe = osu_path.join("EZPPLauncher").join("patcher").join("osu!.patcher.exe");
|
let patcher_exe = osu_path
|
||||||
|
.join("EZPPLauncher")
|
||||||
|
.join("patcher")
|
||||||
|
.join("osu!.patcher.exe");
|
||||||
if patcher_exe.is_file() {
|
if patcher_exe.is_file() {
|
||||||
let _ = crate::utils::ensure_patcher_compatibility(&patcher_exe);
|
let _ = crate::utils::ensure_patcher_compatibility(&patcher_exe);
|
||||||
}
|
}
|
||||||
@@ -1938,7 +1941,8 @@ pub(crate) fn theme_root() -> Result<PathBuf, String> {
|
|||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
fn loopback_theme_asset_base() -> String {
|
fn loopback_theme_asset_base() -> String {
|
||||||
if crate::theme_server::base_url().is_none()
|
if crate::theme_server::base_url().is_none()
|
||||||
&& let Ok(root) = theme_root() {
|
&& let Ok(root) = theme_root()
|
||||||
|
{
|
||||||
match crate::theme_server::media_root() {
|
match crate::theme_server::media_root() {
|
||||||
Ok(media) => {
|
Ok(media) => {
|
||||||
if let Err(error) = crate::theme_server::start(root, media) {
|
if let Err(error) = crate::theme_server::start(root, media) {
|
||||||
@@ -2097,7 +2101,14 @@ pub async fn optimize_theme_media(app: AppHandle, source_url: String) -> Result<
|
|||||||
};
|
};
|
||||||
|
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
optimize_theme_media_blocking(&ffmpeg, &source, &original, &cache_name, &destination, on_progress)
|
optimize_theme_media_blocking(
|
||||||
|
&ffmpeg,
|
||||||
|
&source,
|
||||||
|
&original,
|
||||||
|
&cache_name,
|
||||||
|
&destination,
|
||||||
|
on_progress,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(|error| format!("Theme media optimizer thread failed: {error}"))?
|
.map_err(|error| format!("Theme media optimizer thread failed: {error}"))?
|
||||||
@@ -2258,8 +2269,11 @@ async fn download_ffmpeg(app: &AppHandle) -> Result<PathBuf, String> {
|
|||||||
.await
|
.await
|
||||||
.map_err(|error| format!("Could not write the FFmpeg archive: {error}"))?;
|
.map_err(|error| format!("Could not write the FFmpeg archive: {error}"))?;
|
||||||
|
|
||||||
if let Some(percent) = (received.min(total) * 100).checked_div(total).map(|v| v as u8)
|
if let Some(percent) = (received.min(total) * 100)
|
||||||
&& percent != last_percent {
|
.checked_div(total)
|
||||||
|
.map(|v| v as u8)
|
||||||
|
&& percent != last_percent
|
||||||
|
{
|
||||||
last_percent = percent;
|
last_percent = percent;
|
||||||
let _ = app.emit(
|
let _ = app.emit(
|
||||||
"theme-media-progress",
|
"theme-media-progress",
|
||||||
@@ -2715,8 +2729,11 @@ pub async fn open_presence_editor(app: AppHandle) -> Result<(), String> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let window =
|
let window = WebviewWindowBuilder::new(
|
||||||
WebviewWindowBuilder::new(&app, "presence-editor", WebviewUrl::App("index.html".into()))
|
&app,
|
||||||
|
"presence-editor",
|
||||||
|
WebviewUrl::App("index.html".into()),
|
||||||
|
)
|
||||||
.title("EZPPLauncher — Discord Rich Presence Editor")
|
.title("EZPPLauncher — Discord Rich Presence Editor")
|
||||||
.inner_size(1200.0, 800.0)
|
.inner_size(1200.0, 800.0)
|
||||||
.min_inner_size(980.0, 650.0)
|
.min_inner_size(980.0, 650.0)
|
||||||
@@ -3118,7 +3135,8 @@ fn collect_theme_asset_refs(value: &Value, assets: &mut HashSet<String>) {
|
|||||||
for (key, value) in object {
|
for (key, value) in object {
|
||||||
if (key == "src" || key == "preview")
|
if (key == "src" || key == "preview")
|
||||||
&& let Some(src) = value.as_str()
|
&& let Some(src) = value.as_str()
|
||||||
&& let Some(path) = theme_asset_reference(src) {
|
&& let Some(path) = theme_asset_reference(src)
|
||||||
|
{
|
||||||
assets.insert(path);
|
assets.insert(path);
|
||||||
}
|
}
|
||||||
collect_theme_asset_refs(value, assets);
|
collect_theme_asset_refs(value, assets);
|
||||||
|
|||||||
Reference in new issue
Block a user