diff --git a/routes/__pycache__/room_files.cpython-313.pyc b/routes/__pycache__/room_files.cpython-313.pyc index e94e7fd..0562f90 100644 Binary files a/routes/__pycache__/room_files.cpython-313.pyc and b/routes/__pycache__/room_files.cpython-313.pyc differ diff --git a/routes/room_files.py b/routes/room_files.py index 5bd7da9..fd3065c 100644 --- a/routes/room_files.py +++ b/routes/room_files.py @@ -676,7 +676,18 @@ def delete_permanent(room_id): if rf.type == 'file': os.remove(file_path) elif rf.type == 'folder': + # For folders, we need to delete all contents recursively shutil.rmtree(file_path) + + # Also delete all database records for files and subfolders + folder_path = os.path.join(rf.path, rf.name) if rf.path else rf.name + contained_items = RoomFile.query.filter( + RoomFile.room_id == room_id, + RoomFile.path.like(f"{folder_path}%") + ).all() + + for item in contained_items: + db.session.delete(item) except Exception as e: print(f"Error deleting {rf.type} from storage: {e}")