@@ -764,11 +764,18 @@ async def _list_all(self, force=False):
764764 if not self .fetch :
765765 self .lock .acquire ()
766766 self .fetch = True
767+ def stop (tqdm : Optional [tqdm ] = None ):
768+ if tqdm is not None :
769+ del tqdm
770+ self .lock .acquire ()
771+ self .fetch = False
772+ raise asyncio .CancelledError
767773 try :
768774 await self ._mkdir (self ._download_endpoint ())
769775 r = await self ._execute (self .session .list (self ._download_endpoint ()))
770776 if r is asyncio .CancelledError :
771777 self .lock .acquire ()
778+ self .fetch = False
772779 raise asyncio .CancelledError
773780 dirs = r [1 :]
774781 with tqdm (
@@ -778,9 +785,7 @@ async def _list_all(self, force=False):
778785 await dashboard .set_status_by_tqdm ("storage.webdav" , pbar )
779786 r = await self ._execute (self .session .list (self ._download_endpoint ()))
780787 if r is asyncio .CancelledError :
781- self .lock .acquire ()
782- del pbar
783- raise asyncio .CancelledError
788+ return stop (pbar )
784789 for dir in r [1 :]:
785790 pbar .update (1 )
786791 files : dict [str , File ] = {}
@@ -793,9 +798,7 @@ async def _list_all(self, force=False):
793798 )
794799 )
795800 if r is asyncio .CancelledError :
796- self .lock .acquire ()
797- del pbar
798- raise asyncio .CancelledError
801+ return stop (pbar )
799802 for file in r [1 :]:
800803 if file ["isdir" ]:
801804 continue
@@ -807,9 +810,7 @@ async def _list_all(self, force=False):
807810 try :
808811 await asyncio .sleep (0 )
809812 except asyncio .CancelledError :
810- self .lock .acquire ()
811- del pbar
812- raise asyncio .CancelledError
813+ return stop (pbar )
813814 except Exception as e :
814815 raise e
815816 for remove in set (
@@ -864,7 +865,7 @@ async def get(self, hash: str, offset: int = 0) -> File:
864865 f .expiry = time .time () + CACHE_TIME
865866 self .cache [hash ] = f
866867 elif resp .status // 100 == 3 :
867- f .size = self .get_size (hash )
868+ f .size = await self .get_size (hash )
868869 f .path = resp .headers .get ("Location" )
869870 expiry = re .search (r"max-age=(\d+)" , resp .headers .get ("Cache-Control" , "" )) or 0
870871 if expiry == 0 :
0 commit comments