Fix permanent delete

This commit is contained in:
2025-05-27 11:43:10 +02:00
parent e5d54c499b
commit a67470d616
11 changed files with 176 additions and 126 deletions

View File

@@ -652,14 +652,16 @@ def delete_permanent(room_id):
if not rf:
continue
# Delete the file from storage if it's a file
if rf.type == 'file':
try:
file_path = os.path.join(get_room_dir(room_id), rf.path, rf.name)
if os.path.exists(file_path):
# Delete the file/folder from storage
try:
file_path = os.path.join(get_room_dir(room_id), rf.path, rf.name)
if os.path.exists(file_path):
if rf.type == 'file':
os.remove(file_path)
except Exception as e:
print(f"Error deleting file from storage: {e}")
elif rf.type == 'folder':
shutil.rmtree(file_path)
except Exception as e:
print(f"Error deleting {rf.type} from storage: {e}")
# Delete the database record
db.session.delete(rf)