diff options
author | Mats Wichmann <mats@linux.com> | 2020-12-04 23:52:55 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2020-12-04 23:52:55 (GMT) |
commit | 75ff4da60792a2f6734a3402345cc19825584558 (patch) | |
tree | 45628771b42aeb0ce138af256d3c98fef49c2adb /SCons/dblite.py | |
parent | eb9cd2e2c153be1a1da1466098aae068e8bd6ecc (diff) | |
download | SCons-75ff4da60792a2f6734a3402345cc19825584558.zip SCons-75ff4da60792a2f6734a3402345cc19825584558.tar.gz SCons-75ff4da60792a2f6734a3402345cc19825584558.tar.bz2 |
[PR #3837] retry sconsign replacement on fail
The pending change stopped fiddling to try to get around an
unwritable .sconsign.dblite which needs updating - this is
apparently expected to work, so added a retry with some
permission fiddling.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'SCons/dblite.py')
-rw-r--r-- | SCons/dblite.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/SCons/dblite.py b/SCons/dblite.py index f744c9a..7b5f513 100644 --- a/SCons/dblite.py +++ b/SCons/dblite.py @@ -73,6 +73,7 @@ class dblite: _os_chown = None _os_replace = os.replace + _os_chmod = os.chmod _shutil_copyfile = shutil.copyfile _time_time = time.time @@ -147,12 +148,20 @@ class dblite: self._check_writable() with self._open(self._tmp_name, "wb", self._mode) as f: self._pickle_dump(self._dict, f, self._pickle_protocol) - self._os_replace(self._tmp_name, self._file_name) + + try: + self._os_replace(self._tmp_name, self._file_name) + except PermissionError: + # if we couldn't replace due to perms, try to fiddle them and retry + self._os_chmod(self._file_name, 0o777) + self._os_replace(self._tmp_name, self._file_name) + if self._os_chown is not None and self._chown_to > 0: # don't chown to root or -1 try: self._os_chown(self._file_name, self._chown_to, self._chgrp_to) except OSError: pass + self._needs_sync = False if KEEP_ALL_FILES: self._shutil_copyfile( |