Commit 7948f050 authored by Jim Fulton's avatar Jim Fulton

Added logic to make sure open files don't get caught in exception

stack traces.
parent b15f9568
......@@ -623,7 +623,13 @@ def rename_or_copy_blob(f1, f2, chmod=True):
os.rename(f1, f2)
except OSError:
copied("Copied blob file %r to %r.", f1, f2)
utils.cp(open(f1, 'rb'), open(f2, 'wb'))
file1 = open(f1, 'rb')
file2 = open(f2, 'wb')
try:
utils.cp(file1, file2)
finally:
file1.close()
file2.close()
os.unlink(f1)
if chmod:
os.chmod(f2, stat.S_IREAD)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment