From 584af01366588fd86297b10664da8c975de57ec7 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Mon, 30 Oct 2023 02:35:18 +0300 Subject: [PATCH] fix --- server.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index df13031..634f042 100644 --- a/server.py +++ b/server.py @@ -79,14 +79,18 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo os.makedirs(dir_last) if not os.path.exists(dir_stable): os.makedirs(dir_stable) - os.remove(f"{dir_file}/{filename}") + + if os.path.exists(f"{dir_file}/{filename}"): + os.remove(f"{dir_file}/{filename}") with open(f"{dir_file}/{filename}", 'a') as f: f.write(str(contents)) - os.remove(f"{dir_last}/{filename}") + if os.path.exists(f"{dir_last}/{filename}"): + os.remove(f"{dir_last}/{filename}") with open(f"{dir_last}/{filename}", 'a') as f: f.write(str(contents)) if stable: - os.remove(f"{dir_stable}/{filename}") + if os.path.exists(f"{dir_stable}/{filename}"): + os.remove(f"{dir_stable}/{filename}") with open(f"{dir_stable}/{filename}", 'a') as f: f.write(str(contents)) except Exception as err: