mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 10:16:14 +01:00
- always close the file
This commit is contained in:
parent
8d1c1804bf
commit
f1a04bc50d
23
osc/core.py
23
osc/core.py
@ -2707,19 +2707,20 @@ def get_source_file(apiurl, prj, package, filename, targetfilename=None, revisio
|
||||
query = { 'rev': revision }
|
||||
o = None
|
||||
try:
|
||||
(fd, tmpfile) = tempfile.mkstemp(prefix = filename, suffix = '.osc')
|
||||
o = os.fdopen(fd, 'wb')
|
||||
u = makeurl(apiurl, ['source', prj, package, pathname2url(filename)], query=query)
|
||||
for buf in streamfile(u, http_GET, BUFSIZE):
|
||||
o.write(buf)
|
||||
o.close()
|
||||
shutil.move(tmpfile, targetfilename or filename)
|
||||
except:
|
||||
try:
|
||||
(fd, tmpfile) = tempfile.mkstemp(prefix = filename, suffix = '.osc')
|
||||
o = os.fdopen(fd, 'wb')
|
||||
u = makeurl(apiurl, ['source', prj, package, pathname2url(filename)], query=query)
|
||||
for buf in streamfile(u, http_GET, BUFSIZE):
|
||||
o.write(buf)
|
||||
o.close()
|
||||
shutil.move(tmpfile, targetfilename or filename)
|
||||
except:
|
||||
os.unlink(tmpfile)
|
||||
raise
|
||||
finally:
|
||||
if o is not None:
|
||||
o.close()
|
||||
os.unlink(tmpfile)
|
||||
raise
|
||||
|
||||
|
||||
def get_binary_file(apiurl, prj, repo, arch,
|
||||
filename,
|
||||
|
Loading…
Reference in New Issue
Block a user