Mercurial > treepkg > treepkg
comparison treepkg/info/data.py @ 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 | 3a3cad8f6f60 |
children | 3a5dd6f98f71 |
comparison
equal
deleted
inserted
replaced
504:dcec034fed97 | 505:b7aad4cb58bb |
---|---|
76 row = self.cursor.fetchone() | 76 row = self.cursor.fetchone() |
77 if not row: | 77 if not row: |
78 return None | 78 return None |
79 return Package(*row) | 79 return Package(*row) |
80 | 80 |
81 def get_old_packages(self, newfiles): | 81 def get_old_packages(self, newpackages): |
82 ''' | |
83 Returns a list of all packages that are not in | |
84 newpackages and have a valid track. Therefore packages | |
85 from a not provided track aren't listed. | |
86 ''' | |
82 SELECT_TMPL = """SELECT * FROM packages | 87 SELECT_TMPL = """SELECT * FROM packages |
83 WHERE filename not in (%s)""" | 88 WHERE filename not in (%s) and trackname in (%s)""" |
84 tmp = ", ".join(['?'] * len(newfiles)) | 89 newfiles = [p.filename for p in newpackages] |
85 self.cursor.execute(SELECT_TMPL % tmp, newfiles) | 90 tracknames = list(set([p.tackname for p in newpackages])) |
91 tmp1 = ", ".join(['?'] * len(newfiles)) | |
92 tmp2 = ", ".join(['?'] * len(tracknames)) | |
93 | |
94 self.cursor.execute(SELECT_TMPL % (tmp1, tmp2), newfiles + tracknames) | |
86 return [Package(*row) for row in self.cursor.fetchall()] | 95 return [Package(*row) for row in self.cursor.fetchall()] |
87 | 96 |
88 def remove_packages(self, packages): | 97 def remove_packages(self, packages): |
89 DELET_TMPL = """DELETE FROM packages | 98 DELET_TMPL = """DELETE FROM packages |
90 WHERE filename in (%s)""" | 99 WHERE filename in (%s)""" |