Skip to content

Commit

Permalink
Merge pull request #257 from dale-primer-e/40-backing-up-releases-usi…
Browse files Browse the repository at this point in the history
…ng-fine-grained-token-ends-with-an-error

234 Backing up releases using fine grained token ends with an error
  • Loading branch information
josegonzalez authored Mar 17, 2024
2 parents 0cc50bc + 9812988 commit 2cd9061
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions github_backup/github_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,19 @@ def redirect_request(self, req, fp, code, msg, headers, newurl):
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
if os.path.exists(path):
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("Authorization", "Basic ".encode("ascii") + auth)
opener = build_opener(S3HTTPRedirectHandler)

try:
Expand Down Expand Up @@ -1255,6 +1260,8 @@ def backup_releases(args, repo_cwd, repository, repos_template, include_assets=F
asset["url"],
os.path.join(release_assets_cwd, asset["name"]),
get_auth(args),
as_app=args.as_app,
fine=True if args.token_fine is not None else False
)


Expand Down

0 comments on commit 2cd9061

Please sign in to comment.