File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -75,11 +75,21 @@ async def delete_file(self, text: str):
7575 filepath = await self .get_filepath (text )
7676 if filepath .exists ():
7777 await asyncio .to_thread (os .remove , filepath )
78+ await asyncio .to_thread (self .judge_delete_folder , filepath )
7879
7980 async def delete_files (self , texts ):
8081 tasks = [self .delete_file (text ) for text in texts ]
8182 await asyncio .gather (* tasks )
8283
84+ def judge_delete_folder (self , filepath ):
85+ currpath = os .path .dirname (filepath )
86+ if os .listdir (currpath ):
87+ return
88+ while str (currpath ) != (str (self .DATA_ROOT ) + '\\ upload' ):
89+ if not os .listdir (currpath ):
90+ os .rmdir (os .path .abspath (currpath ))
91+ currpath = os .path .dirname (currpath )
92+
8393
8494STORAGE_ENGINE = {
8595 "filesystem" : FileSystemStorage
You can’t perform that action at this time.
0 commit comments