a few tweaks to speed up the database creation
authorSeth Vidal <skvidal@fedoraproject.org>
Tue, 11 Mar 2008 21:17:16 +0000 (17:17 -0400)
committerSeth Vidal <skvidal@fedoraproject.org>
Tue, 11 Mar 2008 21:17:16 +0000 (17:17 -0400)
createrepo/__init__.py
createrepo/utils.py

index 2a8b06a138b88865dbb127a96eb98fc09bf585bf..1d539b3179cef3a462a40ee8f4d469adfe9cfb95 100644 (file)
@@ -907,8 +907,6 @@ class SplitMetaDataGenerator(MetaDataGenerator):
 
 class MetaDataSqlite(object):
     def __init__(self, destdir):
-        #open the files up
-        #get the cursors - store them in self
         self.pri_sqlite_file = os.path.join(destdir, 'primary.sqlite')
         self.pri_cx = sqlite.Connection(self.pri_sqlite_file)
         self.file_sqlite_file = os.path.join(destdir, 'filelists.sqlite')
@@ -917,9 +915,11 @@ class MetaDataSqlite(object):
         self.other_cx = sqlite.Connection(self.other_sqlite_file)
 
         self.primary_cursor = self.pri_cx.cursor()
+
         self.filelists_cursor = self.file_cx.cursor()
-        self.other_cursor = self.other_cx.cursor()
         
+        self.other_cursor = self.other_cx.cursor()
+                
         self.create_primary_db()
         self.create_filelists_db()
         self.create_other_db()
@@ -927,6 +927,8 @@ class MetaDataSqlite(object):
     def create_primary_db(self):
         # make the tables
         schema = [
+        """PRAGMA synchronous = 0;""",
+        """pragma locking_mode = EXCLUSIVE;""",
         """CREATE TABLE conflicts (  name TEXT,  flags TEXT,  epoch TEXT,  version TEXT,  release TEXT,  pkgKey INTEGER );""",
         """CREATE TABLE db_info (dbversion INTEGER, checksum TEXT);""",
         """CREATE TABLE files (  name TEXT,  type TEXT,  pkgKey INTEGER);""",
@@ -959,6 +961,8 @@ class MetaDataSqlite(object):
 
     def create_filelists_db(self):
         schema = [
+            """PRAGMA synchronous = 0;""",
+            """pragma locking_mode = EXCLUSIVE;""",
             """CREATE TABLE db_info (dbversion INTEGER, checksum TEXT);""",
             """CREATE TABLE filelist (  pkgKey INTEGER,  dirname TEXT,  filenames TEXT,  filetypes TEXT);""",
             """CREATE TABLE packages (  pkgKey INTEGER PRIMARY KEY,  pkgId TEXT);""",
@@ -976,6 +980,8 @@ class MetaDataSqlite(object):
         
     def create_other_db(self):
         schema = [
+            """PRAGMA synchronous = 0;""",
+            """pragma locking_mode = EXCLUSIVE;""",
             """CREATE TABLE changelog (  pkgKey INTEGER,  author TEXT,  date INTEGER,  changelog TEXT);""",
             """CREATE TABLE db_info (dbversion INTEGER, checksum TEXT);""",
             """CREATE TABLE packages (  pkgKey INTEGER PRIMARY KEY,  pkgId TEXT);""",
index a8a8fb75bd10ad0261f00c874255c95a5d8801a7..ffd7f140a1538bffd5282d0632b35c526b69c644 100644 (file)
@@ -142,9 +142,9 @@ def encodefilenamelist(filenamelist):
 
 def encodefiletypelist(filetypelist):
     result = ''
-
+    ftl = {'file':'f', 'dir':'d', 'ghost':'g'}
     for x in filetypelist:
-        result += x[0]
+        result += ftl[x]
     return result