From 268f176c75d6a8b4f92efbfa7e8367f1d63d8889 Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Tue, 24 May 2011 22:01:35 -0700
Subject: [PATCH] dblink: use config._init_dirs() when necessary

---
 pym/portage/dbapi/vartree.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index aa57ab74f..1c0890683 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -3637,9 +3637,13 @@ class dblink(object):
 		# write out our collection of md5sums
 		if cfgfiledict != cfgfiledict_orig:
 			cfgfiledict.pop("IGNORE", None)
-			ensure_dirs(os.path.dirname(conf_mem_file),
-				gid=portage_gid, mode=0o2750, mask=0o2)
-			writedict(cfgfiledict, conf_mem_file)
+			try:
+				writedict(cfgfiledict, conf_mem_file)
+			except IOError as e:
+				if e.errno != errno.ENOENT:
+					raise
+				self.settings._init_dirs()
+				writedict(cfgfiledict, conf_mem_file)
 
 		return os.EX_OK
 
-- 
2.26.2