cache.sqlite: handle readonly
authorZac Medico <zmedico@gentoo.org>
Thu, 12 May 2011 18:42:08 +0000 (11:42 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 May 2011 19:19:49 +0000 (12:19 -0700)
pym/portage/cache/sqlite.py

index d15b6ece12a3bb69a7cdd7a96024c5a163085aa2..4eb340bb00726dbebb487d55d43eea05540f57d2 100644 (file)
@@ -31,7 +31,7 @@ class database(fs_template.FsBased):
                self.location = os.path.join(self.location, 
                        self.label.lstrip(os.path.sep).rstrip(os.path.sep))
 
-               if not os.path.exists(self.location):
+               if not self.readonly and not os.path.exists(self.location):
                        self._ensure_dirs()
 
                config.setdefault("autocommit", self.autocommits)
@@ -72,7 +72,8 @@ class database(fs_template.FsBased):
                connection_kwargs = {}
                connection_kwargs["timeout"] = config["timeout"]
                try:
-                       self._ensure_dirs()
+                       if not self.readonly:
+                               self._ensure_dirs()
                        self._db_connection = self._db_module.connect(
                                database=_unicode_decode(self._dbpath), **connection_kwargs)
                        self._db_cursor = self._db_connection.cursor()