permanent delete folders fix
This commit is contained in:
Binary file not shown.
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user