feat: attempt to download package from GITEA repo directly when access via anonymous user
This commit is contained in:
parent
0e46cc5f89
commit
112c42fc86
|
@ -491,18 +491,25 @@ class ArtifactHelper:
|
|||
elif self._repo_type == "GITEA":
|
||||
check_url = f"{self._host}/api/v1/packages/{subrepo}/generic/{pkg_name}/{ver}/files"
|
||||
r = requests.get(check_url, **auth_opts)
|
||||
if not r.ok:
|
||||
W(f"The file {fname}({ver}) is not existing in GITEA generic repo, HTTP code: {r.status_code}, {r.text}!")
|
||||
return False
|
||||
jobj = r.json()
|
||||
for item in jobj:
|
||||
if item['name'] == fname:
|
||||
break
|
||||
# Authorization is requried, attempt to download directly, never check whether it is existent
|
||||
if f.status_code == 401:
|
||||
pass
|
||||
else:
|
||||
W(f"Can not find {fname}({ver}) in GITEA generic repo!")
|
||||
return False
|
||||
if not r.ok:
|
||||
W(f"The file {fname}({ver}) is not existing in GITEA generic repo, HTTP code: {r.status_code}, {r.text}!")
|
||||
return False
|
||||
jobj = r.json()
|
||||
for item in jobj:
|
||||
if item['name'] == fname:
|
||||
break
|
||||
else:
|
||||
W(f"Can not find {fname}({ver}) in GITEA generic repo!")
|
||||
return False
|
||||
|
||||
r = requests.get(url, stream=True, **auth_opts)
|
||||
if not r.ok:
|
||||
W(f"Failed to download package {fname}({ver})!")
|
||||
return False
|
||||
fpath = os.path.abspath(fpath)
|
||||
|
||||
if os.path.isdir(fpath):
|
||||
|
|
Loading…
Reference in New Issue