mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-12 20:58:28 +03:00
urlfetcher: Unlink file if download is aborted
This commit is contained in:
parent
c9af3f94ce
commit
102a49771f
@ -211,13 +211,19 @@ class _URLFetcher(object):
|
||||
prefix = "virtinst-" + os.path.basename(filename) + "."
|
||||
|
||||
# pylint: disable=redefined-variable-type
|
||||
fileobj = tempfile.NamedTemporaryFile(
|
||||
dir=self.scratchdir, prefix=prefix, delete=False)
|
||||
fn = fileobj.name
|
||||
fn = None
|
||||
try:
|
||||
fileobj = tempfile.NamedTemporaryFile(
|
||||
dir=self.scratchdir, prefix=prefix, delete=False)
|
||||
fn = fileobj.name
|
||||
|
||||
self._grabURL(filename, fileobj)
|
||||
logging.debug("Saved file to %s", fn)
|
||||
return fn
|
||||
self._grabURL(filename, fileobj)
|
||||
logging.debug("Saved file to %s", fn)
|
||||
return fn
|
||||
except: # noqa
|
||||
if fn and os.path.exists(fn):
|
||||
os.unlink(fn)
|
||||
raise
|
||||
|
||||
def acquireFileContent(self, filename):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user