aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-12-06 15:05:36 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2014-12-06 15:05:36 +0100
commita57b51f7d8239120e8cdd08f972af8e79c894388 (patch)
tree43ba9dd2ebb2b808e33890144ab8c308807e0dc7
parentd34e06f27741fdff8e5a8d43d5908c69e8697fe7 (diff)
Check for previous builds at import.
* This is done to make sure we are not importing new build documents when we already parsed them. Change-Id: Ia57d49aa7f511c4958ab21bcd000e9c2e14a6497
-rw-r--r--app/utils/docimport.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/app/utils/docimport.py b/app/utils/docimport.py
index 7776f7d..7680c29 100644
--- a/app/utils/docimport.py
+++ b/app/utils/docimport.py
@@ -216,12 +216,29 @@ def _traverse_defconf_dir(
defconfig_doc.dirname = defconfig_dir
if all([defconfig_doc, database]):
- prev_doc = utils.db.find_one(
+ spec = {
+ models.JOB_KEY: defconfig_doc.job,
+ models.KERNEL_KEY: defconfig_doc.kernel,
+ models.DEFCONFIG_KEY: defconfig_doc.defconfig,
+ models.DEFCONFIG_FULL_KEY: defconfig_doc.defconfig_full,
+ models.ARCHITECTURE_KEY: defconfig_doc.arch
+ }
+ prev_doc = utils.db.find(
database[models.DEFCONFIG_COLLECTION],
- [defconfig_doc.name],
- field=models.NAME_KEY)
- if prev_doc:
- defconfig_doc.id = prev_doc[models.ID_KEY]
+ 0,
+ 0,
+ spec=spec
+ )
+
+ prev_doc_count = prev_doc.count()
+ if prev_doc_count > 0:
+ if prev_doc_count == 1:
+ defconfig_doc.id = prev_doc[0].get(models.ID_KEY, None)
+ else:
+ utils.LOG.warn(
+ "Found multiple defconfig docs matching: %s",
+ spec)
+ utils.LOG.error("Cannot save keeping old document id")
else:
utils.LOG.warn("No build data file found in '%s'", real_dir)