virt-manager: prefer os.makedirs to os.mkdir when creating cache dir

Ensure the parent directories exist when attempting to create the
cache directory.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1016435

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2013-11-01 13:26:24 +01:00
parent 395a20edd8
commit 5798c5b9b4
3 changed files with 3 additions and 3 deletions

View File

@ -316,7 +316,7 @@ class vmmConnection(vmmGObject):
uri = self.get_uri().replace("/", "_")
ret = os.path.join(util.get_cache_dir(), uri)
if not os.path.exists(ret):
os.mkdir(ret, 755)
os.makedirs(ret, 0755)
return ret
def get_default_storage_format(self):

View File

@ -1649,7 +1649,7 @@ class vmmDomain(vmmLibvirtObject):
def get_cache_dir(self):
ret = os.path.join(self.conn.get_cache_dir(), self.get_uuid())
if not os.path.exists(ret):
os.mkdir(ret, 0755)
os.makedirs(ret, 0755)
return ret

View File

@ -155,7 +155,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
raise RuntimeError("No write access to directory %s" % vi_dir)
try:
os.mkdir(vi_dir, 0751)
os.makedirs(vi_dir, 0751)
except IOError, e:
raise RuntimeError("Could not create directory %s: %s" %
(vi_dir, e))