Fix permissions on already-extracted sidecar dirs
The chmod fix only ran after fresh extraction, but existing sidecar dirs extracted by older versions still lacked execute permissions. Now set_executable_permissions() runs on EVERY app launch (both the early-return path for existing dirs and after fresh extraction). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,9 @@ impl SidecarManager {
|
||||
|
||||
// Already extracted — use it directly
|
||||
if binary_path.exists() {
|
||||
// Ensure all binaries are executable (fixes previously extracted dirs)
|
||||
#[cfg(unix)]
|
||||
Self::set_executable_permissions(&extract_dir);
|
||||
Self::cleanup_old_sidecars(data_dir, ¤t_version);
|
||||
return Ok(binary_path);
|
||||
}
|
||||
@@ -113,23 +116,8 @@ impl SidecarManager {
|
||||
));
|
||||
}
|
||||
|
||||
// Make all binaries executable on Unix (sidecar, ffmpeg, ffprobe, etc.)
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
if let Ok(entries) = std::fs::read_dir(&extract_dir) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.is_file() {
|
||||
if let Ok(meta) = std::fs::metadata(&path) {
|
||||
let mut perms = meta.permissions();
|
||||
perms.set_mode(0o755);
|
||||
let _ = std::fs::set_permissions(&path, perms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::set_executable_permissions(&extract_dir);
|
||||
|
||||
Self::cleanup_old_sidecars(data_dir, ¤t_version);
|
||||
Ok(binary_path)
|
||||
@@ -214,6 +202,24 @@ impl SidecarManager {
|
||||
|
||||
/// Remove old sidecar-* directories that don't match the current version.
|
||||
/// Called after the current version's sidecar is confirmed ready.
|
||||
/// Set execute permissions on all files in a directory (Unix only).
|
||||
#[cfg(unix)]
|
||||
fn set_executable_permissions(dir: &Path) {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
if let Ok(entries) = std::fs::read_dir(dir) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.is_file() {
|
||||
if let Ok(meta) = std::fs::metadata(&path) {
|
||||
let mut perms = meta.permissions();
|
||||
perms.set_mode(0o755);
|
||||
let _ = std::fs::set_permissions(&path, perms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn cleanup_old_sidecars(data_dir: &Path, current_version: &str) {
|
||||
let current_dir_name = format!("sidecar-{}", current_version);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user