changeset 505:b7aad4cb58bb

don't remove packages if a track is deactivated
author Bjoern Ricks <bricks@intevation.de>
date Fri, 05 Nov 2010 10:52:06 +0000
parents dcec034fed97
children 3a5dd6f98f71
files bin/publishdebianpackages.py treepkg/info/data.py
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bin/publishdebianpackages.py	Mon Oct 25 14:30:08 2010 +0000
+++ b/bin/publishdebianpackages.py	Fri Nov 05 10:52:06 2010 +0000
@@ -122,8 +122,7 @@
                         scp_flags=scp_flags, cachedir=destdir))
 
 def remove_old_packages(cachedb, newpackages, quiet):
-    newfiles = [package.filename for package in newpackages]
-    oldpackages = cachedb.get_old_packages(newfiles)
+    oldpackages = cachedb.get_old_packages(newpackages)
     for package in oldpackages:
         # better check if the file really exists
         if os.path.isfile(package.filename):
--- a/treepkg/info/data.py	Mon Oct 25 14:30:08 2010 +0000
+++ b/treepkg/info/data.py	Fri Nov 05 10:52:06 2010 +0000
@@ -78,11 +78,20 @@
             return None
         return Package(*row) 
 
-    def get_old_packages(self, newfiles):
+    def get_old_packages(self, newpackages):
+        '''
+        Returns a list of all packages that are not in
+        newpackages and have a valid track. Therefore packages
+        from a not provided track aren't listed.
+        '''
         SELECT_TMPL = """SELECT * FROM packages 
-                      WHERE filename not in (%s)"""
-        tmp = ", ".join(['?'] * len(newfiles))
-        self.cursor.execute(SELECT_TMPL % tmp, newfiles)
+                      WHERE filename not in (%s) and trackname in (%s)"""
+        newfiles = [p.filename for p in newpackages]
+        tracknames = list(set([p.tackname for p in newpackages]))
+        tmp1 = ", ".join(['?'] * len(newfiles))
+        tmp2 = ", ".join(['?'] * len(tracknames))
+
+        self.cursor.execute(SELECT_TMPL % (tmp1, tmp2), newfiles + tracknames)
         return [Package(*row) for row in self.cursor.fetchall()]
 
     def remove_packages(self, packages):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)