Changeset - 103bb1129d44
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 6 years ago 2020-02-06 03:39:22
mads@kiilerich.com
ssh: use py3 os.replace
1 file changed with 2 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/model/ssh_key.py
Show inline comments
 
@@ -134,8 +134,5 @@ class SshKeyModel(object):
 
            for key in UserSshKeys.query().join(UserSshKeys.user).filter(User.active == True):
 
                f.write(ssh.authorized_keys_line(kallithea_cli_path, config['__file__'], key))
 
        os.chmod(tmp_authorized_keys, stat.S_IRUSR | stat.S_IWUSR)
 
        # This preliminary remove is needed for Windows, not for Unix.
 
        # TODO In Python 3, the remove+rename sequence below should become os.replace.
 
        if os.path.exists(authorized_keys):
 
            os.remove(authorized_keys)
 
        os.rename(tmp_authorized_keys, authorized_keys)
 
        # Note: simple overwrite / rename isn't enough to replace the file on Windows
 
        os.replace(tmp_authorized_keys, authorized_keys)
0 comments (0 inline, 0 general)