Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit da1fca4

Browse files
committed
catch missing etag
1 parent c1bf540 commit da1fca4

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

swift_upload_runner/download.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ def download_into_queue(
126126
self.content_type = req.headers["Content-Type"]
127127
except KeyError:
128128
self.content_type = "binary/octet-stream"
129-
self.chksum = req.headers["ETag"]
129+
if "ETag" in req.headers:
130+
self.chksum = req.headers["ETag"]
131+
else:
132+
LOGGER.error("ETag missing, maybe segments file empty")
133+
raise aiohttp.web.HTTPUnprocessableEntity(
134+
reason="ETag missing, maybe segments file empty"
135+
)
130136
self.mtime = int(float(req.headers["X-Timestamp"]))
131137
self.size = int(req.headers["Content-Length"])
132138
for chunk in req.iter_content(chunk_size=self.chunk_size):

swift_upload_runner/replicate.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ async def a_sync_object_segments(
161161
LOGGER.debug(f"Copying segment {segment}")
162162
headers["Content-Length"] = str(length)
163163
headers["Content-Type"] = resp_g.headers["Content-Type"]
164-
headers["ETag"] = resp_g.headers["ETag"]
164+
if "ETag" in resp_g.headers:
165+
headers["ETag"] = resp_g.headers["ETag"]
166+
else:
167+
LOGGER.error("ETag missing, maybe segments file empty")
168+
raise aiohttp.web.HTTPUnprocessableEntity(
169+
reason="ETag missing, maybe segments file empty"
170+
)
165171

166172
to_url = common.generate_download_url(
167173
self.host,
@@ -236,7 +242,13 @@ async def a_copy_object(
236242
LOGGER.debug(f"Copying object {object_name} in full.")
237243
headers["Content-Length"] = str(length)
238244
headers["Content-Type"] = resp_g.headers["Content-Type"]
239-
headers["ETag"] = resp_g.headers["ETag"]
245+
if "ETag" in resp_g.headers:
246+
headers["ETag"] = resp_g.headers["ETag"]
247+
else:
248+
LOGGER.error("ETag missing, maybe segments file empty")
249+
raise aiohttp.web.HTTPUnprocessableEntity(
250+
reason="ETag missing, maybe segments file empty"
251+
)
240252
async with self.client.put(
241253
common.generate_download_url(
242254
self.host,

0 commit comments

Comments
 (0)