Fix std::os::unix included on Windows where it doesnt exist, and remove set permission in yt-dlp for anything other than unix altogether.

This commit is contained in:
csd4ni3l
2026-03-05 22:36:47 +01:00
parent 8d21c268c2
commit ff947b57a8

View File

@@ -1,7 +1,10 @@
use std::{env::current_dir, fs::{File, exists}, io, os::unix::fs::PermissionsExt, process::Command}; use std::{env::current_dir, fs::{File, exists}, io, process::Command};
use reqwest; use reqwest;
use rfd::{MessageButtons, MessageDialog, MessageDialogResult}; use rfd::{MessageButtons, MessageDialog, MessageDialogResult};
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
pub fn get_yt_dlp_path() -> String { pub fn get_yt_dlp_path() -> String {
if cfg!(target_os = "windows"){ if cfg!(target_os = "windows"){
current_dir().expect("Failed to get current working directory").join("bin").join("yt-dlp.exe").to_string_lossy().to_string() current_dir().expect("Failed to get current working directory").join("bin").join("yt-dlp.exe").to_string_lossy().to_string()
@@ -40,6 +43,8 @@ pub fn check_and_download_yt_dlp() {
let mut body = reqwest::blocking::get(url).expect("Could not download yt-dlp"); let mut body = reqwest::blocking::get(url).expect("Could not download yt-dlp");
let mut out = File::create(get_yt_dlp_path()).expect("failed to create file"); let mut out = File::create(get_yt_dlp_path()).expect("failed to create file");
io::copy(&mut body, &mut out).expect("failed to copy content"); io::copy(&mut body, &mut out).expect("failed to copy content");
#[cfg(unix)]
out.set_permissions(PermissionsExt::from_mode(0o755)); out.set_permissions(PermissionsExt::from_mode(0o755));
} }