0001-qommon-storage-in-_atomic_write-do-not-create-temp-f.patch
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 |
- |