Make icon theme cover file writing atomic

This commit is contained in:
Kovid Goyal 2019-10-21 08:43:37 +05:30
parent efb6405ff1
commit 3bf65b261e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -475,8 +475,10 @@ def get_cover(metadata):
etag = etag.decode('utf-8')
cached, etag = download_cover(metadata['cover-url'], etag, cached)
if cached:
with open(cover_file, 'wb') as f:
aname = cover_file + '.atomic'
with open(aname, 'wb') as f:
f.write(cached)
atomic_rename(aname, cover_file)
if etag:
with open(etag_file, 'wb') as f:
f.write(as_bytes(etag))