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: