mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 16:18:02 +01:00
Merge pull request #257 from dale-primer-e/40-backing-up-releases-using-fine-grained-token-ends-with-an-error
234 Backing up releases using fine grained token ends with an error
This commit is contained in:
@@ -777,14 +777,19 @@ class S3HTTPRedirectHandler(HTTPRedirectHandler):
|
|||||||
return request
|
return request
|
||||||
|
|
||||||
|
|
||||||
def download_file(url, path, auth):
|
def download_file(url, path, auth, as_app=False, fine=False):
|
||||||
# Skip downloading release assets if they already exist on disk so we don't redownload on every sync
|
# Skip downloading release assets if they already exist on disk so we don't redownload on every sync
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
return
|
return
|
||||||
|
|
||||||
request = Request(url)
|
request = _construct_request(per_page=100,
|
||||||
|
page=1,
|
||||||
|
query_args={},
|
||||||
|
template=url,
|
||||||
|
auth=auth,
|
||||||
|
as_app=as_app,
|
||||||
|
fine=fine)
|
||||||
request.add_header("Accept", "application/octet-stream")
|
request.add_header("Accept", "application/octet-stream")
|
||||||
request.add_header("Authorization", "Basic ".encode("ascii") + auth)
|
|
||||||
opener = build_opener(S3HTTPRedirectHandler)
|
opener = build_opener(S3HTTPRedirectHandler)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -1255,6 +1260,8 @@ def backup_releases(args, repo_cwd, repository, repos_template, include_assets=F
|
|||||||
asset["url"],
|
asset["url"],
|
||||||
os.path.join(release_assets_cwd, asset["name"]),
|
os.path.join(release_assets_cwd, asset["name"]),
|
||||||
get_auth(args),
|
get_auth(args),
|
||||||
|
as_app=args.as_app,
|
||||||
|
fine=True if args.token_fine is not None else False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user