From 3e3451adda28c3f2d1d8c169f255f5a9ae7c5639 Mon Sep 17 00:00:00 2001 From: Kobe Date: Tue, 27 May 2025 11:55:54 +0200 Subject: [PATCH] permanent delete folders fix --- routes/__pycache__/room_files.cpython-313.pyc | Bin 37698 -> 38323 bytes routes/room_files.py | 11 +++++++++++ 2 files changed, 11 insertions(+) diff --git a/routes/__pycache__/room_files.cpython-313.pyc b/routes/__pycache__/room_files.cpython-313.pyc index e94e7fde7e934a124a1814e2d35b2c48348a03ee..0562f902aab259a6483bd5a544e52563e6dda441 100644 GIT binary patch delta 824 zcmZutT}YE*6h80g_POty`_WDJIbF_8H>aixU6wy-iA`)X=2&Rfh4@2%EE|DkP(o$? zr=E+nE>wtI1gS`1Hwhuxg%_@*QAvMz6G|uw-9_)0?ap)Y9L{;4=Q-~=ub(ip&lu&l zLcs%#onFVejSDl%o{sD#z{GZW?vH1#Nea8P34->(8YXF#eR&@ zZn7F2?LSD~;c~y_)|yuTz&-39x2T*``d!b}o8f8uR&4Nxp)QHWS(Zvv-w#`GTeMGV<=*Rd`J}lTmf-RW#LCD>T zq7OSUz{&6P-F#S<7?LH9n8Gr{RspE??G&P6z+*Pjg%@&lbum) z@{3MArf7@FdG<1s*V&6s{@KmV<$ITbftx{r0V+JNTV%3BkEp(IFsA{dDI>%Z6$V9y zXcGvVfq|VNQ5EP2j%ah3NU$Kt4g)@hV4+YBJ_chJm_`K#d4^!1Qb!KI3J9IXn8sks zEYFa}s3|h}RFC&$sa_36g~`snt!lS8T`Q7P3raHc^NJ<`jV|H`5$iz2dJwSzNN93S z-q#{IS*%Z*`4(g9;7uNp4{RKhOZ&|jFHT<5 zucm%SL~6S4B;N&^S44Eaa4~Rl_j7e}UFVRz$RRmH=^BUZM@0sHxi2b{dnW`c$pfu9 zqUXfnq0My6Tn$K`(B|@#Vm)Ch?J3H7Qk2zGYBS@+Su7HojB1~m8JGk>gcsvS79hVU H5~vpd|Eqcd 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}")