From c3bb70d2d53f5e89b0bb9b8b98ce9ce476e26a96 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Thu, 13 Apr 2023 12:35:31 +0300 Subject: [PATCH] load stable cdn --- cdncli.py | 9 ++++++++- server.py | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cdncli.py b/cdncli.py index 2fea7e6..b457262 100644 --- a/cdncli.py +++ b/cdncli.py @@ -37,6 +37,13 @@ parser.add_argument( help='Файл билда' ) +parser.add_argument( + '-st', + '--stable', + action='store_true', + help='Стабильная версия' +) + if __name__ == '__main__': args = parser.parse_args() @@ -71,7 +78,7 @@ if __name__ == '__main__': if os.path.exists(filepath): file = {'file': open(filepath, 'rb')} res = requests.post(url='https://cdn.itguild.info/uploadfile/', - files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file}) + files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file, 'stable': args.stable}) if res.ok: print(f"Successfully uploaded {filepath}") print(res.text) diff --git a/server.py b/server.py index 8af7162..0afbf19 100644 --- a/server.py +++ b/server.py @@ -65,7 +65,7 @@ async def create_file(file: Annotated[bytes | None, File()] = None): @app.post("/uploadfile/") async def create_upload_file(file: UploadFile | None, package: Annotated[str, Form()], version: Annotated[str, Form()], - filename: Annotated[str, Form()]): + filename: Annotated[str, Form()], stable: Annotated[bool, Form()] | None): try: contents = file.file.read() dir_file = "packages/{package}/{version}".format(package=package, version=version) @@ -81,6 +81,9 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo f.write(contents) with open(f"{dir_last}/{filename}", 'wb') as f: f.write(contents) + if stable: + with open(f"{dir_stable}/{filename}", 'wb') as f: + f.write(contents) except Exception as err: return {"message": "There was an error uploading the file, error {err}".format(err=err)} finally: