]> git.ipfire.org Git - pakfire.git/commitdiff
Create a local SOLV file that contains all package information.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 20 Nov 2011 11:39:39 +0000 (12:39 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 20 Nov 2011 11:39:39 +0000 (12:39 +0100)
Reading the sqlite is very slow (however) and as we like to
have a very great user experience, we can cache all information
that is needed by the solver.
For anything else, the full sqlite database is kept and we rely on
that in the first place.

python/pakfire/constants.py
python/pakfire/repository/base.py
python/pakfire/repository/index.py
python/pakfire/transaction.py

index 21819198ed78bb89e694b9a26339640133213741..e396888bef4569431cc980b9f962867e2a29baef 100644 (file)
@@ -42,6 +42,7 @@ LOCAL_TMP_PATH = "/var/tmp"
 
 PACKAGES_DB_DIR = "var/lib/pakfire"
 PACKAGES_DB = os.path.join(PACKAGES_DB_DIR, "packages.db")
+PACKAGES_SOLV = os.path.join(PACKAGES_DB_DIR, "packages.solv")
 REPOSITORY_DB = "index.db"
 
 BUFFER_SIZE = 102400
index 56ece2ea17876ae0fe357464f76362b15c63d707..e606826c11c25f69624274c979ff92c1f7ac776f 100644 (file)
@@ -127,6 +127,12 @@ class RepositoryFactory(object):
                assert self.index
                self.index.clear()
 
+       def commit(self):
+               """
+                       Commit repository data to disk.
+               """
+               self.index.commit()
+
        def dump(self, long=False, filelist=False):
                dumps = []
                # Dump all package information of the packages in this repository.
index a73fa76a96bb4af93bd4e2e8ef00438874d5ef84..c43303f32eeccc897001989af001643e76a75ac2 100644 (file)
@@ -83,6 +83,12 @@ class Index(object):
                """
                self.solver_repo.write(filename)
 
+       def commit(self):
+               """
+                       Commit index data to disk.
+               """
+               pass
+
        def create_relation(self, *args, **kwargs):
                return self.pakfire.create_relation(*args, **kwargs)
 
@@ -407,6 +413,19 @@ class IndexLocal(Index):
        def init(self):
                self.db = database.DatabaseLocal(self.pakfire, self.repo)
 
+               if os.path.exists(PACKAGES_SOLV):
+                       self.read(PACKAGES_SOLV)
+
+       def commit(self):
+               # Write SOLV cache file.
+               filename = os.path.join(self.pakfire.path, PACKAGES_SOLV)
+
+               dirname = os.path.dirname(filename)
+               if not os.path.exists(dirname):
+                       os.makedirs(dirname)
+
+               self.write(filename)
+
        def check(self):
                # XXX Create the database and lock it or something.
                pass
index 11a05efe30278ab6b71a5ec3776d97295c6d34ec..ec54b1c33b981b7f51d5baf01caa19c752e83408 100644 (file)
@@ -203,6 +203,11 @@ class Transaction(object):
 
                return transaction
 
+       @property
+       def local(self):
+               # Shortcut to local repository.
+               return self.pakfire.repos.local
+
        def add(self, action_name, pkg):
                assert isinstance(pkg, packages.SolvPackage), pkg
 
@@ -427,5 +432,8 @@ class Transaction(object):
 
                log.info("")
 
+               # Commit repository metadata.
+               self.local.commit()
+
                # Call sync to make sure all buffers are written to disk.
                sync()