Compare commits

...

6 Commits

Author SHA1 Message Date
b51ee3db69 fix mod 2023-10-31 00:53:04 +03:00
584af01366 fix 2023-10-30 02:35:18 +03:00
7be0209169 fix save file 2023-10-30 02:29:47 +03:00
7e8afb21ec fix save file 2023-10-30 02:15:27 +03:00
104401dab9 file mod 2023-10-30 02:02:47 +03:00
7e604c2feb fix write 2023-10-30 01:27:13 +03:00

View File

@ -1,3 +1,4 @@
import pathlib
from typing import Union, Annotated from typing import Union, Annotated
import uvicorn import uvicorn
from routes.user_routes import user_route from routes.user_routes import user_route
@ -78,12 +79,19 @@ 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)
with open(f"{dir_file}/{filename}", 'a') as f:
if os.path.exists(f"{dir_file}/{filename}"):
os.remove(f"{dir_file}/{filename}")
with open(f"{dir_file}/{filename}", 'wb') as f:
f.write(contents) f.write(contents)
with open(f"{dir_last}/{filename}", 'a') as f: if os.path.exists(f"{dir_last}/{filename}"):
os.remove(f"{dir_last}/{filename}")
with open(f"{dir_last}/{filename}", 'wb') as f:
f.write(contents) f.write(contents)
if stable: if stable:
with open(f"{dir_stable}/{filename}", 'a') as f: if os.path.exists(f"{dir_stable}/{filename}"):
os.remove(f"{dir_stable}/{filename}")
with open(f"{dir_stable}/{filename}", 'wb') as f:
f.write(contents) f.write(contents)
except Exception as err: except Exception as err:
return {"message": "There was an error uploading the file, error {err}".format(err=err)} return {"message": "There was an error uploading the file, error {err}".format(err=err)}