load stable cdn
This commit is contained in:
parent
2a1c24cda1
commit
c3bb70d2d5
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user