]> git.ipfire.org Git - people/ms/pakfire.git/blobdiff - python/pakfire/repository/database.py
database: Save installed package size.
[people/ms/pakfire.git] / python / pakfire / repository / database.py
index 4c5084c21a95612bfc237bdd44ae24d23e9720e9..fc8a1a94229cfeebe96fd08ee841f37699e972e8 100644 (file)
@@ -31,6 +31,7 @@ log = logging.getLogger("pakfire")
 import pakfire.packages as packages
 
 from pakfire.constants import *
+from pakfire.errors import *
 from pakfire.i18n import _
 
 class Cursor(sqlite3.Cursor):
@@ -118,6 +119,10 @@ class DatabaseLocal(Database):
 
                Database.__init__(self, pakfire, filename)
 
+       def initialize(self):
+               # Open the database.
+               self.open()
+
                # Check if we actually can open the database.
                if not self.format in DATABASE_FORMATS_SUPPORTED:
                        raise DatabaseFormatError, _("The format of the database is not supported by this version of pakfire.")
@@ -260,6 +265,9 @@ class DatabaseLocal(Database):
                if self.format < 5:
                        c.execute("ALTER TABLE files ADD COLUMN datafile INTEGER AFTER config")
 
+               if self.format < 6:
+                       c.execute("ALTER TABLE packages ADD COLUMN inst_size INTEGER AFTER size")
+
                # In the end, we can easily update the version of the database.
                c.execute("UPDATE settings SET val = ? WHERE key = 'version'", (DATABASE_FORMAT,))
                self.__format = DATABASE_FORMAT
@@ -283,6 +291,7 @@ class DatabaseLocal(Database):
                                        groups,
                                        filename,
                                        size,
+                                       inst_size,
                                        hash1,
                                        provides,
                                        requires,
@@ -302,7 +311,7 @@ class DatabaseLocal(Database):
                                        installed,
                                        repository,
                                        reason
-                               ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
+                               ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
                                (
                                        pkg.name,
                                        pkg.epoch,
@@ -312,6 +321,7 @@ class DatabaseLocal(Database):
                                        " ".join(pkg.groups),
                                        pkg.filename,
                                        pkg.size,
+                                       pkg.inst_size,
                                        pkg.hash1,
                                        "\n".join(pkg.provides),
                                        "\n".join(pkg.requires),