Browse Source

preserve file permissions when saving wallet

283
ThomasV 9 years ago
parent
commit
a9f451decd
  1. 4
      lib/wallet.py

4
lib/wallet.py

@ -125,6 +125,8 @@ class WalletStorage(PrintError):
f.write(s) f.write(s)
f.flush() f.flush()
os.fsync(f.fileno()) os.fsync(f.fileno())
mode = os.stat(self.path).st_mode if os.path.exists(self.path) else stat.S_IREAD | stat.S_IWRITE
# perform atomic write on POSIX systems # perform atomic write on POSIX systems
try: try:
os.rename(temp_path, self.path) os.rename(temp_path, self.path)
@ -133,7 +135,7 @@ class WalletStorage(PrintError):
os.rename(temp_path, self.path) os.rename(temp_path, self.path)
if 'ANDROID_DATA' not in os.environ: if 'ANDROID_DATA' not in os.environ:
import stat import stat
os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE) os.chmod(self.path, mode)
self.print_error("saved") self.print_error("saved")

Loading…
Cancel
Save