mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 04:57:54 +00:00
fileutil.py: use try/finally to close file in write_atomically.
This commit is contained in:
parent
959248cd49
commit
3738c3e2d1
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user