From 58c1d3d44b1d862329ad972f008b347a74875940 Mon Sep 17 00:00:00 2001 From: ZHYCarge <8144808+zhycarge@user.noreply.gitee.com> Date: Fri, 23 Dec 2022 18:09:22 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=BD=93=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=96=87=E4=BB=B6=E8=A2=AB=E5=88=A0=E9=99=A4=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E6=95=B4=E4=B8=AA=E5=AD=98=E6=94=BE?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storage.py b/storage.py index 1d22a3f..5fd4c05 100644 --- a/storage.py +++ b/storage.py @@ -75,11 +75,21 @@ class FileSystemStorage: filepath = await self.get_filepath(text) if filepath.exists(): await asyncio.to_thread(os.remove, filepath) + await asyncio.to_thread(self.judge_delete_folder, filepath) async def delete_files(self, texts): tasks = [self.delete_file(text) for text in texts] await asyncio.gather(*tasks) + def judge_delete_folder(self, filepath): + currpath = os.path.dirname(filepath) + if os.listdir(currpath): + return + while str(currpath) != (str(self.DATA_ROOT) + '\\upload'): + if not os.listdir(currpath): + os.rmdir(os.path.abspath(currpath)) + currpath = os.path.dirname(currpath) + STORAGE_ENGINE = { "filesystem": FileSystemStorage