From 8887e727cac3a1b6377096e5bd759a3918660ae5 Mon Sep 17 00:00:00 2001 From: None <62809003+Arrowar@users.noreply.github.com> Date: Wed, 16 Apr 2025 10:21:50 +0200 Subject: [PATCH] Update ffmpeg_installer.py --- StreamingCommunity/Util/ffmpeg_installer.py | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/StreamingCommunity/Util/ffmpeg_installer.py b/StreamingCommunity/Util/ffmpeg_installer.py index 3b13eac..8d16e5b 100644 --- a/StreamingCommunity/Util/ffmpeg_installer.py +++ b/StreamingCommunity/Util/ffmpeg_installer.py @@ -219,13 +219,26 @@ class FFMPEGDownloader: with open(final_path, 'wb') as f_out: shutil.copyfileobj(f_in, f_out) - # Set executable permissions - os.chmod(final_path, 0o755) - logging.info(f"Successfully extracted {gz_path} to {final_path}") - - # Remove the gzip file - os.remove(gz_path) - return True + # Set executable permissions with more explicit error handling + try: + current_perms = os.stat(final_path).st_mode + new_perms = current_perms | 0o755 # Add execute permission while preserving other bits + os.chmod(final_path, new_perms) + logging.info(f"Successfully set permissions {oct(new_perms)} for {final_path}") + except OSError as e: + logging.error(f"Failed to set executable permissions on {final_path}: {e}") + return False + + # Verify the file is executable + if not os.access(final_path, os.X_OK): + logging.error(f"File {final_path} is not executable after chmod") + return False + + logging.info(f"Successfully extracted {gz_path} to {final_path}") + + # Remove the gzip file + os.remove(gz_path) + return True except Exception as e: logging.error(f"Extraction error for {gz_path}: {e}") @@ -346,4 +359,4 @@ def check_ffmpeg() -> Tuple[Optional[str], Optional[str], Optional[str]]: except Exception as e: logging.error(f"Error checking or downloading FFmpeg executables: {e}") - return None, None, None \ No newline at end of file + return None, None, None