Skip to content

Commit

Permalink
Merge pull request #557 from dargueta/fix-missing-etag
Browse files Browse the repository at this point in the history
Fix #477 -- Don't set IfMatch if ETag is missing
  • Loading branch information
martindurant committed Nov 18, 2021
2 parents 12cb258 + 0390617 commit d17605c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ def __init__(
self.append_block = True
self.loc = loc

if "r" in mode:
if "r" in mode and "ETag" in self.details:
self.req_kw["IfMatch"] = self.details["ETag"]

def _call_s3(self, method, *kwarglist, **kwargs):
Expand Down Expand Up @@ -1883,7 +1883,7 @@ def setxattr(self, copy_kwargs=None, **kwargs):
"""
if self.writable():
raise NotImplementedError(
"cannot update metadata while file " "is open for writing"
"cannot update metadata while file is open for writing"
)
return self.fs.setxattr(self.path, copy_kwargs=copy_kwargs, **kwargs)

Expand All @@ -1906,7 +1906,7 @@ def _fetch_range(self, start, end):
except OSError as ex:
if ex.args[0] == errno.EINVAL and "pre-conditions" in ex.args[1]:
raise FileExpired(
filename=self.details["name"], e_tag=self.details["ETag"]
filename=self.details["name"], e_tag=self.details.get("ETag")
) from ex
else:
raise
Expand Down

0 comments on commit d17605c

Please sign in to comment.