From faa86e27febffeee4ea27452c91fd78f3c516891 Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Tue, 22 Jan 2019 09:38:45 +0100
Subject: [PATCH] [bootstrap] Fix deployment if cache is not yet filled

---
 bob/devtools/bootstrap.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/bob/devtools/bootstrap.py b/bob/devtools/bootstrap.py
index 744c6a99..53371d3b 100644
--- a/bob/devtools/bootstrap.py
+++ b/bob/devtools/bootstrap.py
@@ -166,12 +166,18 @@ def merge_conda_cache(cache, prefix, name):
   logger.info('Merging urls.txt files from cache...')
   urls = []
   cached_pkgs_urls_txt = os.path.join(cached_pkgs_dir, 'urls.txt')
-  logger.info('touch %s', cached_pkgs_urls_txt)
-  touch(cached_pkgs_urls_txt)  #sometimes it does not exist yet
-  with open(pkgs_urls_txt, 'rb') as f1, \
-      open(cached_pkgs_urls_txt, 'rb') as f2:
-    data = set(f1.readlines() + f2.readlines())
-    data = sorted(list(data))
+
+  if not os.path.exists(cached_pkgs_urls_txt):
+    with open(pkgs_urls_txt, 'rb') as f1:
+      data = set(f1.readlines())
+      data = sorted(list(data))
+  else:
+    # use both cached and actual conda package caches
+    with open(pkgs_urls_txt, 'rb') as f1, \
+        open(cached_pkgs_urls_txt, 'rb') as f2:
+      data = set(f1.readlines() + f2.readlines())
+      data = sorted(list(data))
+
   with open(pkgs_urls_txt, 'wb') as f:
     f.writelines(data)
 
-- 
GitLab