Skip to content

Commit

Permalink
gs: More robust expired auth token detection for uploads (s3ql#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
d--j authored Jan 4, 2021
1 parent 933fc0a commit d3be7d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
`umount.s3ql`, `umount`, or `fusermount -u` and wait for the mount.s3ql process to
terminate.

* More robust expired auth token detection for Google Storage.


2020-11-09, S3QL 3.6.0

Expand Down
9 changes: 4 additions & 5 deletions src/s3ql/backends/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,11 @@ def write_fh(self, fh, key: str, md5: bytes,
raise ValueError('md5 passed to write_fd does not match fd data')

resp = self.conn.read_response()
if resp.status != 200:
# If we're really unlucky, then the token has expired while we were uploading data.
if resp.status == 401:
raise AccessTokenExpired()
elif resp.status != 200:
exc = self._parse_error_response(resp)
# If we're really unlucky, then the token has expired while we
# were uploading data.
if exc.message == 'Invalid Credentials':
raise AccessTokenExpired()
raise _map_request_error(exc, key) or exc
self._parse_json_response(resp)

Expand Down

0 comments on commit d3be7d3

Please sign in to comment.