Fix Memory leak(maybe)

This commit is contained in:
tr1x_em committed 2025-08-06 18:44:43 +05:30
1 parent 6de682784e
commit 7d169ce1ef
4 files changed
+180 -54

No files matched your search

+4 -4
View File
@@ -816,16 +816,16 @@ class PlayerBox(Box):
if self._download_cancelled:
return
# Clean up old temp files first (keep only last 2 to avoid excessive cleanup)
if len(self.temp_artwork_files) > 2:
old_files = self.temp_artwork_files[:-2]
# Clean up old temp files first (keep only last 1 to reduce memory)
if len(self.temp_artwork_files) > 1:
old_files = self.temp_artwork_files[:-1]
for old_file in old_files:
try:
if os.path.exists(old_file):
os.unlink(old_file)
except Exception:
pass
self.temp_artwork_files = self.temp_artwork_files[-2:]
self.temp_artwork_files = self.temp_artwork_files[-1:]
# Check again if cancelled
if self._download_cancelled: