Bug 900444 - Mozprofile writes permissions inefficiently, r=jgriffin
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 01 Aug 2013 16:42:32 -0400
changeset 140946 019c4e995db4f2d120540b62b16d2d44cf4b7488
parent 140945 9b8647516b359d60f475fc3cd7dc114c49528b63
child 140947 0066614e509f3734a8840e082f5f4e609a682be5
push id31933
push userahalberstadt@mozilla.com
push dateThu, 01 Aug 2013 20:43:41 +0000
treeherdermozilla-inbound@019c4e995db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs900444
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 900444 - Mozprofile writes permissions inefficiently, r=jgriffin
testing/mozbase/mozprofile/mozprofile/permissions.py
--- a/testing/mozbase/mozprofile/mozprofile/permissions.py
+++ b/testing/mozbase/mozprofile/mozprofile/permissions.py
@@ -237,36 +237,36 @@ class Permissions(object):
         cursor.execute("""CREATE TABLE IF NOT EXISTS moz_hosts (
            id INTEGER PRIMARY KEY,
            host TEXT,
            type TEXT,
            permission INTEGER,
            expireType INTEGER,
            expireTime INTEGER)""")
 
+        rows = cursor.execute("PRAGMA table_info(moz_hosts)")
+        count = len(rows.fetchall())
+
+        # if the db contains 8 columns, we're using user_version 3
+        if count == 8:
+            statement = "INSERT INTO moz_hosts values(NULL, ?, ?, ?, 0, 0, 0, 0)"
+            cursor.execute("PRAGMA user_version=3;")
+        else:
+            statement = "INSERT INTO moz_hosts values(NULL, ?, ?, ?, 0, 0)"
+            cursor.execute("PRAGMA user_version=2;")
+
         for location in locations:
             # set the permissions
             permissions = { 'allowXULXBL': 'noxul' not in location.options }
             for perm, allow in permissions.iteritems():
                 if allow:
                     permission_type = 1
                 else:
                     permission_type = 2
 
-                rows = cursor.execute("PRAGMA table_info(moz_hosts)")
-                count = len(rows.fetchall())
-
-                # if the db contains 8 columns, we're using user_version 3
-                if count == 8:
-                    statement = "INSERT INTO moz_hosts values(NULL, ?, ?, ?, 0, 0, 0, 0)"
-                    cursor.execute("PRAGMA user_version=3;")
-                else:
-                    statement = "INSERT INTO moz_hosts values(NULL, ?, ?, ?, 0, 0)"
-                    cursor.execute("PRAGMA user_version=2;")
-
                 cursor.execute(statement,
                                (location.host, perm, permission_type))
 
         # Commit and close
         permDB.commit()
         cursor.close()
 
     def network_prefs(self, proxy=None):