From 9999260adaee4a2a70f502104ba627bd43d4413c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 2 Nov 2011 11:11:35 +0100 Subject: [PATCH] Speed up searching for files that need to be removed. --- po/pakfire.pot | 2 +- python/pakfire/packages/installed.py | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/po/pakfire.pot b/po/pakfire.pot index 0f87a8e77..3bd08653a 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-25 20:58+0200\n" +"POT-Creation-Date: 2011-10-25 21:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/pakfire/packages/installed.py b/python/pakfire/packages/installed.py index 207252495..ba7cbab76 100644 --- a/python/pakfire/packages/installed.py +++ b/python/pakfire/packages/installed.py @@ -280,19 +280,23 @@ class DatabasePackage(Package): # Fetch the whole filelist of the system from the database and create # a diff. Exclude files from this package - of course. - c.execute("SELECT name FROM files WHERE pkg != ?", (self.id,)) + c.execute("SELECT DISTINCT name FROM files WHERE pkg != ?", (self.id,)) + installed_files = set() for row in c: - # Check if file in filelist. - for f in files: - if not row["name"] == f.name: - continue - - files.remove(f) - break + installed_files.add(row["name"]) c.close() - self._remove_files(files, message, prefix) + # List with files to be removed. + remove_files = [] + + for f in files: + if f.name in installed_files: + continue + + remove_files.append(f) + + self._remove_files(remove_files, message, prefix) # XXX maybe we can remove this later? -- 2.39.5