Skip to content

Commit 6b7d2a3

Browse files
committed
Fixing Sentry.io OPENSHOT-E5: Access is denied / PermissionError during auto save. Quite this a bit, logging a warning instead of an error.
1 parent 31d0a4e commit 6b7d2a3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/windows/main_window.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -702,16 +702,31 @@ def auto_save_project(self):
702702

703703
# Delete recovery files which are 'too old'
704704
for backup_filepath in old_backup_files:
705-
os.unlink(backup_filepath)
705+
try:
706+
if os.path.exists(backup_filepath):
707+
os.unlink(backup_filepath)
708+
log.info(f"Deleted backup file: {backup_filepath}")
709+
else:
710+
log.warning(f"File not found: {backup_filepath}")
711+
except PermissionError:
712+
log.warning(f"Permission denied: {backup_filepath}. Unable to delete.")
713+
except Exception as e:
714+
log.error(f"Error deleting file {backup_filepath}: {e}", exc_info=True)
706715

707716
# Save project
708717
log.info("Auto save project file: %s", file_path)
709718
self.save_project(file_path)
710719

711720
# Remove backup.osp (if any)
712721
if os.path.exists(info.BACKUP_FILE):
713-
# Delete backup.osp since we just saved the actual project
714-
os.unlink(info.BACKUP_FILE)
722+
try:
723+
# Delete backup.osp since we just saved the actual project
724+
os.unlink(info.BACKUP_FILE)
725+
log.info(f"Deleted backup file: {info.BACKUP_FILE}")
726+
except PermissionError:
727+
log.warning(f"Permission denied: {info.BACKUP_FILE}. Unable to delete.")
728+
except Exception as e:
729+
log.error(f"Error deleting file {info.BACKUP_FILE}: {e}", exc_info=True)
715730

716731
else:
717732
# No saved project found

0 commit comments

Comments
 (0)