Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backing up releases using fine grained token ends with an error #257

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading