createrepo/__init__.py createrepo/utils.py

[email protected] (Seth Vidal)
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
 createrepo/__init__.py |   12 +++++++++---
 createrepo/utils.py    |    4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 0224a9123168f67103b0aa498695b5f8c6921cff
Author: Seth Vidal <[email protected]>
Date:   Tue Mar 11 17:17:16 2008 -0400

    a few tweaks to speed up the database creation

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 2a8b06a..1d539b3 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -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);""",
diff --git a/createrepo/utils.py b/createrepo/utils.py
index a8a8fb7..ffd7f14 100644
--- a/createrepo/utils.py
+++ b/createrepo/utils.py
@@ -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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.