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: