projects
/
tahoe-lafs
/
tahoe-lafs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
959248c
)
fileutil.py: use try/finally to close file in write_atomically.
author
david-sarah
<david-sarah@jacaranda.org>
Wed, 16 May 2012 23:08:39 +0000
(23:08 +0000)
committer
david-sarah
<david-sarah@jacaranda.org>
Wed, 16 May 2012 23:08:39 +0000
(23:08 +0000)
src/allmydata/util/fileutil.py
patch
|
blob
|
history
diff --git
a/src/allmydata/util/fileutil.py
b/src/allmydata/util/fileutil.py
index d6235509848cf53fc3928da9044b57a6175476dd..7add35cb41a968c2952c17e159b00eca149cde00 100644
(file)
--- a/
src/allmydata/util/fileutil.py
+++ b/
src/allmydata/util/fileutil.py
@@
-249,8
+249,10
@@
def move_into_place(source, dest):
def write_atomically(target, contents, mode="b"):
f = open(target+".tmp", "w"+mode)
- f.write(contents)
- f.close()
+ try:
+ f.write(contents)
+ finally:
+ f.close()
move_into_place(target+".tmp", target)
def write(path, data):