From 754ef0aaca2a50bd2473fb78f990c9c8005364c6 Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Fri, 22 Sep 2017 12:10:24 +0200
Subject: [PATCH] Check for conda-folder exists?

---
 gitlab/functions.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index 6ab06be..cf1fde3 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -268,12 +268,14 @@ fi
 # $1: Path to where to install miniconda. The path should not exist.
 install_miniconda() {
   log_info "Installing miniconda in ${1} ..."
+
   # Download the latest conda installation script
   if [ "${OSNAME}" == "macosx" ]; then
     object=https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
   else
     object=https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
   fi
+
   # check if miniconda.sh exists
   if [ ! -e miniconda.sh ]; then
     log_info "Downloading latest miniconda3 installer..."
@@ -282,21 +284,27 @@ install_miniconda() {
     log_info "Re-using cached miniconda3 installer..."
     ls -l miniconda.sh
   fi
+
   # Check if cache exists and save urls.txt to create a valid cache after conda
   # installation override
   _urls="${1}/pkgs/urls.txt"
   if [ -e ${_urls} ]; then
     run_cmd cp ${_urls} ${_urls}.cached
   fi
+
+  # install miniconda
   bash miniconda.sh -b -p ${1}
+
   # Reset urls.txt
   if [ -e ${_urls}.cached ]; then
     log_info "Merging urls.txt files with cached values..."
     cat ${_urls} ${_urls}.cached | sort | uniq > ${_urls}
   fi
+
   # List currently available packages on cache
   run_cmd ls -l ${1}/pkgs/
   run_cmd cat ${1}/pkgs/urls.txt
+
   hash -r
 }
 
@@ -323,7 +331,7 @@ if [ -z "${CONDA_FOLDER}" ]; then
 fi
 
 # check if a conda installation exists. Otherwise, install one:
-if [ ! -e $1 ]; then
+if [ ! -e ${CONDA_FOLDER} ]; then
   install_miniconda ${CONDA_FOLDER}
 fi
 
-- 
GitLab