Commit 35b1c0a1 authored by Antoine Millet's avatar Antoine Millet
Browse files

Write account configurations in an atomic way

parent 2f3d3355
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -122,7 +122,9 @@ class CCConf(object):
        filename = os.path.join(self._path, '%s.json' % login)
        self.logger.debug('Writing configuration %s: %s', filename, conf)
        if os.path.isfile(filename) ^ create:
            json.dump(conf, open(filename, 'w'))
            with open(filename + '.tmp', 'w') as ftmp:
                json.dump(conf, ftmp)
            os.rename(filename + '.tmp', filename)
        else:
            raise CCConf.UnknownAccount('%s is not a file' % filename)