From ef087d2d9e33a4bc8707163f4152d9fe381b790d Mon Sep 17 00:00:00 2001 From: datawhores Date: Wed, 15 Nov 2023 16:36:23 -0600 Subject: [PATCH] fix fileobject close --- ofscraper/utils/download.py | 5 +++-- ofscraper/utils/downloadbatch.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ofscraper/utils/download.py b/ofscraper/utils/download.py index 132aedbf8..4dd869877 100644 --- a/ofscraper/utils/download.py +++ b/ofscraper/utils/download.py @@ -398,7 +398,7 @@ async def inner(c,ele,path,username,model_id,progress,total): log.debug(f"[bold] {get_medialog(ele)} main download headers [/bold]: {r.headers}") r.raise_for_status() progress.remove_task(task1) - fileobject.close() + await fileobject.close() size_checker(temp,ele,total) await asyncio.get_event_loop().run_in_executor(cache_thread,partial( cache.touch,f"{ele.filename}_headers",1)) return total ,temp,path_to_file @@ -410,7 +410,7 @@ async def inner(c,ele,path,username,model_id,progress,total): except Exception as E: log.traceback(traceback.format_exc()) log.traceback(E) - raise Ef + raise E finally: #Close file if needed try: @@ -597,6 +597,7 @@ async def inner(item,c,ele,progress): log.debug(f"[bold] {get_medialog(ele)} main download data finder headeers [/bold]: {l.headers}") l.raise_for_status() progress.remove_task(task1) + await fileobject.close() size_checker(temp,ele,total) await asyncio.get_event_loop().run_in_executor(cache_thread,partial( cache.touch,f"{item['name']}_headers",1)) return item diff --git a/ofscraper/utils/downloadbatch.py b/ofscraper/utils/downloadbatch.py index 031fa7ebe..3c0a601b8 100644 --- a/ofscraper/utils/downloadbatch.py +++ b/ofscraper/utils/downloadbatch.py @@ -577,7 +577,7 @@ async def inner(c,ele,path,username,model_id,total): innerlog.get().debug(f"[bold] {get_medialog(ele)} main download response text [/bold]: {await r.text_()}") innerlog.get().debug(f"[bold] {get_medialog(ele)}main download headers [/bold]: {r.headers}") r.raise_for_status() - fileobject.close() + await fileobject.close() size_checker(temp,ele,total) await asyncio.get_event_loop().run_in_executor(cache_thread,partial( cache.touch,f"{ele.filename}_headers",1)) return total,temp,path_to_file @@ -770,7 +770,7 @@ async def inner(item,c,ele): innerlog.get().debug(f"[bold] {get_medialog(ele)} main download data finder text [/bold]: {await l.text_()}") innerlog.get().debug(f"[bold] {get_medialog(ele)} main download data finder headeers [/bold]: {l.headers}") l.raise_for_status() - fileobject.close() + await fileobject.close() size_checker(temp,ele,total)