Projet

Général

Profil

0001-qommon-storage-in-_atomic_write-do-not-create-temp-f.patch

Benjamin Dauvergne, 22 novembre 2012 15:13

Télécharger (1,3 ko)

Voir les différences:

Subject: [PATCH] qommon/storage: in _atomic_write do not create temp files in the same directory as the final file

 wcs/qommon/storage.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
wcs/qommon/storage.py
51 51
    '''Rewrite a complete file automatically, that is write to new file with
52 52
    temporary name, fsync, then rename to final name. Use threads to remove blocking.'''
53 53
    def doit():
54
        fd, temp = tempfile.mkstemp(dir=os.path.dirname(path), prefix=os.path.basename(path))
54
        dirname = os.path.dirname(path)
55
        tmpdir = os.path.join(dirname, '.tmp')
56
        if not os.path.exists(tmpdir):
57
            try:
58
                os.mkdir(tmpdir)
59
            except OSError, e:
60
                if e.errno != 17:
61
                    raise
62
        fd, temp = tempfile.mkstemp(dir=tmpdir, prefix=os.path.basename(path))
55 63
        f = os.fdopen(fd, "w")
56 64
        if hasattr(content, 'read'):
57 65
            # file pointer
58
-