aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevan Franchini <twitch153@gentoo.org>2015-08-15 04:00:35 -0400
committerDevan Franchini <twitch153@gentoo.org>2015-08-15 04:00:37 -0400
commita7a267a46660e168bc1d46c4b39c4e89bed20767 (patch)
tree4aec77f4a6643d714353d40673693a40fb65fa4d
parentsqlite_db.py: Modifies owner information gathering method (diff)
downloadlayman-a7a267a46660e168bc1d46c4b39c4e89bed20767.tar.gz
layman-a7a267a46660e168bc1d46c4b39c4e89bed20767.tar.bz2
layman-a7a267a46660e168bc1d46c4b39c4e89bed20767.zip
Adds remove parameter to database write() function
This parameter has been added in order to obtain proper parallelization support for layman sqlite databases. With this additional parameter it prompts the sqlite db module's write function to simply return when removing an overlay, preventing it from re-adding any database entires and causing oddness, run-time errors, or other unwanted badness.
-rw-r--r--layman/db.py2
-rw-r--r--layman/db_modules/json_db/json_db.py2
-rw-r--r--layman/db_modules/sqlite_db/sqlite_db.py11
-rw-r--r--layman/db_modules/xml_db/xml_db.py2
-rw-r--r--layman/dbbase.py4
5 files changed, 12 insertions, 9 deletions
diff --git a/layman/db.py b/layman/db.py
index 673e6bf..a7ed1ce 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -149,7 +149,7 @@ class DB(DbBase):
overlay.delete(self.config['storage'])
repo_ok = self.repo_conf.delete(overlay)
self.remove(overlay, self.path)
- self.write(self.path)
+ self.write(self.path, remove=True)
else:
self.output.error('No local overlay named "' + overlay.name + '"!')
return False
diff --git a/layman/db_modules/json_db/json_db.py b/layman/db_modules/json_db/json_db.py
index d466385..70e41d5 100644
--- a/layman/db_modules/json_db/json_db.py
+++ b/layman/db_modules/json_db/json_db.py
@@ -112,7 +112,7 @@ class DBHandler(object):
del self.overlays[overlay.name]
- def write(self, path):
+ def write(self, path, remove=False):
'''
Write the list of overlays to a file.
'''
diff --git a/layman/db_modules/sqlite_db/sqlite_db.py b/layman/db_modules/sqlite_db/sqlite_db.py
index 6619699..22ae5f3 100644
--- a/layman/db_modules/sqlite_db/sqlite_db.py
+++ b/layman/db_modules/sqlite_db/sqlite_db.py
@@ -283,6 +283,9 @@ class DBHandler(object):
owner_id = 0
source_ids = []
+ if overlay.name in self.overlays:
+ del self.overlays[overlay.name]
+
with self.__connect__(path) as connection:
cursor = connection.cursor()
@@ -318,14 +321,14 @@ class DBHandler(object):
connection.commit()
- if overlay.name in self.overlays:
- del self.overlays[overlay.name]
-
- def write(self, path):
+ def write(self, path, remove=False):
'''
Write the list of overlays to the database.
'''
+ if remove:
+ return
+
try:
with self.__connect__(path) as connection:
for overlay in self.overlays:
diff --git a/layman/db_modules/xml_db/xml_db.py b/layman/db_modules/xml_db/xml_db.py
index 316d8f9..fbd7a6a 100644
--- a/layman/db_modules/xml_db/xml_db.py
+++ b/layman/db_modules/xml_db/xml_db.py
@@ -157,7 +157,7 @@ class DBHandler(object):
del self.overlays[overlay.name]
- def write(self, path):
+ def write(self, path, remove=False):
'''
Write the list of overlays to a file.
'''
diff --git a/layman/dbbase.py b/layman/dbbase.py
index cecbf5c..dc089d8 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -197,7 +197,7 @@ class DbBase(object):
db_ctl.read_db(path, text=text)
- def write(self, path, migrate_type=None):
+ def write(self, path, remove=False, migrate_type=None):
'''
Write the list of overlays to a file.
'''
@@ -212,7 +212,7 @@ class DbBase(object):
self.ignore,
self.ignore_init_read_errors)
- db_ctl.write(path)
+ db_ctl.write(path, remove=remove)
def remove(self, overlay, path):