Made secure_delete_file and cleanup_downloads async in file_ops.py

Added chunked file processing and size limits to prevent blocking
Updated video_downloader.py to properly await secure_delete_file
Updated video_archiver.py to properly await cleanup_downloads
Simplified the secure deletion process while maintaining security
Added proper error handling and logging throughout
This commit is contained in:
pacnpal
2024-11-15 13:47:28 +00:00
parent 0194142c56
commit 0d7b1d449f
3 changed files with 43 additions and 58 deletions

View File

@@ -58,7 +58,7 @@ class VideoArchiver(commands.Cog):
self.download_path.mkdir(parents=True, exist_ok=True)
# Clean existing downloads
cleanup_downloads(str(self.download_path))
await cleanup_downloads(str(self.download_path))
# Initialize shared FFmpeg manager
self.ffmpeg_mgr = FFmpegManager()
@@ -184,7 +184,7 @@ class VideoArchiver(commands.Cog):
# Clean up download directory
if hasattr(self, "download_path") and self.download_path.exists():
try:
cleanup_downloads(str(self.download_path))
await cleanup_downloads(str(self.download_path))
self.download_path.rmdir()
except Exception as e:
logger.error(f"Error cleaning up download directory: {str(e)}")
@@ -202,7 +202,7 @@ class VideoArchiver(commands.Cog):
# Ensure download directory exists and is clean
self.download_path.mkdir(parents=True, exist_ok=True)
cleanup_downloads(str(self.download_path))
await cleanup_downloads(str(self.download_path))
# Clean up old components if they exist
if guild_id in self.components: