]> git.decadent.org.uk Git - dak.git/commitdiff
Add files from .dsc, but not in .changes to changes_pool_files
authorAnsgar Burchardt <ansgar@debian.org>
Fri, 25 Mar 2011 13:15:49 +0000 (13:15 +0000)
committerAnsgar Burchardt <ansgar@debian.org>
Fri, 25 Mar 2011 13:15:49 +0000 (13:15 +0000)
Signed-off-by: Ansgar Burchardt <ansgar@debian.org>
daklib/changes.py

index e016638cd1db36296d67f4ea0505723106ac057e..54adb3b06b4d091a0134df5eff7820daee2ba466 100644 (file)
@@ -187,6 +187,31 @@ class Changes(object):
             if (not self.changes.has_key(key)) or (not self.changes[key]):
                 self.changes[key]='missing'
 
+    def __get_file_from_pool(self, filename, entry, session):
+        cnf = Config()
+
+        poolname = poolify(entry["source"], entry["component"])
+        l = get_location(cnf["Dir::Pool"], entry["component"], session=session)
+
+        found, poolfile = check_poolfile(os.path.join(poolname, filename),
+                                         entry['size'],
+                                         entry["md5sum"],
+                                         l.location_id,
+                                         session=session)
+
+        if found is None:
+            Logger.log(["E: Found multiple files for pool (%s) for %s" % (chg_fn, entry["component"])])
+            return None
+        elif found is False and poolfile is not None:
+            Logger.log(["E: md5sum/size mismatch for %s in pool" % (chg_fn)])
+            return None
+        else:
+            if poolfile is None:
+                Logger.log(["E: Could not find %s in pool" % (chg_fn)])
+                return None
+            else:
+                return poolfile
+
     @session_wrapper
     def add_known_changes(self, dirpath, in_queue=None, session=None):
         """add "missing" in fields which we will require for the known_changes table"""
@@ -248,27 +273,22 @@ class Changes(object):
 
             except IOError:
                 # Can't find the file, try to look it up in the pool
-                poolname = poolify(entry["source"], entry["component"])
-                l = get_location(cnf["Dir::Pool"], entry["component"], session=session)
-
-                found, poolfile = check_poolfile(os.path.join(poolname, chg_fn),
-                                                 entry['size'],
-                                                 entry["md5sum"],
-                                                 l.location_id,
-                                                 session=session)
-
-                if found is None:
-                    Logger.log(["E: Found multiple files for pool (%s) for %s" % (chg_fn, entry["component"])])
-                elif found is False and poolfile is not None:
-                    Logger.log(["E: md5sum/size mismatch for %s in pool" % (chg_fn)])
-                else:
-                    if poolfile is None:
-                        Logger.log(["E: Could not find %s in pool" % (chg_fn)])
-                    else:
-                        chg.poolfiles.append(poolfile)
+                poolfile = self.__get_file_from_pool(chg_fn, entry, session)
+                if poolfile:
+                    chg.poolfiles.append(poolfile)
 
         chg.files = files
 
+        # Add files referenced in .dsc, but not included in .changes
+        for name, entry in self.dsc_files.items():
+            if self.files.has_key(name):
+                continue
+
+            entry['source'] = self.changes['source']
+            poolfile = self.__get_file_from_pool(name, entry, session)
+            if poolfile:
+                chg.poolfiles.append(poolfile)
+
         session.commit()
         chg = session.query(DBChange).filter_by(changesname = self.changes_file).one();