Skip to content
Draft
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
12 changes: 10 additions & 2 deletions knossos/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def work1(self, part):
data.base = link

if result not in (304, True):
# We got an ETag
with open(dest_path + '.etag', 'w') as hdl:
# We got an ETag, write it to a temp file
with open(dest_path + '.etag.tmp', 'w') as hdl:
hdl.write(result)

break
Expand All @@ -106,6 +106,14 @@ def work1(self, part):
with open(dest_path, 'r') as dest:
data.parse(dest.read())

# We've successfully parsed the downloaded data,
# so we know we've got a complete mods.json.
# It's now safe to replace the existing etag file.
if os.path.isfile(dest_path + '.etag'):
os.unlink(dest_path)

os.rename(dest_path + '.etag.tmp', dest_path + '.etag')

self._public = data

except Exception:
Expand Down