This commit is contained in:
Kavalar 2023-10-30 02:35:18 +03:00
parent 7be0209169
commit 584af01366

View File

@ -79,14 +79,18 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo
os.makedirs(dir_last) os.makedirs(dir_last)
if not os.path.exists(dir_stable): if not os.path.exists(dir_stable):
os.makedirs(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: with open(f"{dir_file}/{filename}", 'a') as f:
f.write(str(contents)) 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: with open(f"{dir_last}/{filename}", 'a') as f:
f.write(str(contents)) f.write(str(contents))
if stable: 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: with open(f"{dir_stable}/{filename}", 'a') as f:
f.write(str(contents)) f.write(str(contents))
except Exception as err: except Exception as err: