f"{edition} hash doesn't match X-Database-MD5 header"
)
+ # All python temporary files are hard-coded to mode 0600,
+ # which isn't what we want if we're going to move this one in
+ # to the live database directory. At the very least, we want
+ # it to respect the umask. This gets a little stupid: to
+ # obtain the current umask, you have to change it. We change
+ # it to 0777 (mask all permissions), because that's the only
+ # safe choice, and because the temporary umask we set should
+ # not actually affect anything. Afterwards, we immediate set
+ # the umask (again) to what it was originally. This "gets" the
+ # umask, albeit with extra steps.
+ old_umask = os.umask(0o777)
+ os.umask(old_umask)
+
+ # Finally, we chmod g to be world readable and group writable,
+ # minus whatever the user has set in his umask.
+ os.chmod(g.name, 0o664 & ~old_umask)
+
# Overwrite the old database file with the new (gunzipped) one.
shutil.move(g.name, dbfile)