From a7a04697757d5a2f07a9a2e6af082537fd77f69b Mon Sep 17 00:00:00 2001
From: ArmandBahi <armand.bahi@veremes.com>
Date: Mon, 15 Oct 2018 16:56:17 +0200
Subject: [PATCH] =?UTF-8?q?Permettre=20de=20relancer=20le=20script=20sans?=
 =?UTF-8?q?=20probl=C3=A8mes=20de=20duplication=20des=20symlinks?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 utils/init_symlinks.sh | 45 +++++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/utils/init_symlinks.sh b/utils/init_symlinks.sh
index 0941f2b0..593dcb16 100755
--- a/utils/init_symlinks.sh
+++ b/utils/init_symlinks.sh
@@ -21,25 +21,21 @@ cd ..
 
 # Vitis
 echo "---- Link vitis ----"
-if [ -f "$(pwd)/client" ]; then
-	rm $(pwd)/client
+if ! [ -f "$(pwd)/client" ]; then
+	ln -rsf src/vitis/client client
 fi
-ln -rsf src/vitis/client client
-if [ -f "$(pwd)/vas" ]; then
-	rm $(pwd)/vas
+if ! [ -f "$(pwd)/vas" ]; then
+	ln -rsf src/vitis/vas vas
 fi
-ln -rsf src/vitis/vas vas
 
 # Conf
 echo "---- Link conf ----"
-if [ -f "src/vitis/client/conf" ]; then
-	rm src/vitis/client/conf
+if ! [ -f "src/vitis/client/conf" ]; then
+	ln -rsf conf src/vitis/client/conf
 fi
-ln -rsf conf src/vitis/client/conf
-if [ -f "conf/closure" ]; then
-	rm conf/closure
+if ! [ -f "conf/closure" ]; then
+	ln -rsf src/closure/conf conf/closure
 fi
-ln -rsf src/closure/conf conf/closure
 
 # Modules
 if [[ $depsCount > 0 ]]; then
@@ -49,37 +45,32 @@ if [[ $depsCount > 0 ]]; then
 				module=${aDeps[$i, name]:7}
 				echo "---- Link module_${module} ----"
 				if [ -d "$(pwd)/src/module_${module}/module" ]; then
-					if [ -f "src/vitis/client/modules/${module}" ]; then
-						rm src/vitis/client/modules/${module}
+					if ! [ -f "src/vitis/client/modules/${module}" ]; then
+						ln -rsf src/module_${module}/module src/vitis/client/modules/${module}
 					fi
-					ln -rsf src/module_${module}/module src/vitis/client/modules/${module}
 				fi
 				if [ -d "$(pwd)/src/module_${module}/web_service/ws" ]; then
-					if [ -f "src/vitis/vas/rest/ws/${module}" ]; then
-						rm src/vitis/vas/rest/ws/${module}
+					if ! [ -f "src/vitis/vas/rest/ws/${module}" ]; then
+						ln -rsf src/module_${module}/web_service/ws src/vitis/vas/rest/ws/${module}
 					fi
-					ln -rsf src/module_${module}/web_service/ws src/vitis/vas/rest/ws/${module}
 				fi
 				if [ -d "$(pwd)/src/module_${module}/web_service/conf" ]; then
-					if [ -f "src/vitis/vas/rest/conf/${module}" ]; then
-						rm src/vitis/vas/rest/conf/${module}
+					if ! [ -f "src/vitis/vas/rest/conf/${module}" ]; then
+						ln -rsf src/module_${module}/web_service/conf src/vitis/vas/rest/conf/${module}
 					fi
-					ln -rsf src/module_${module}/web_service/conf src/vitis/vas/rest/conf/${module}
 				fi
 				if [ -d "$(pwd)/src/module_${module}/web_service/sql" ]; then
-					if [ -f "src/vitis/vas/sql/${module}" ]; then
-						rm src/vitis/vas/sql/${module}
+					if ! [ -f "src/vitis/vas/sql/${module}" ]; then
+						ln -rsf src/module_${module}/web_service/sql src/vitis/vas/sql/${module}
 					fi
-					ln -rsf src/module_${module}/web_service/sql src/vitis/vas/sql/${module}
 				fi
 				if [ -d "$(pwd)/src/module_${module}/web_service/class" ]; then
 					for class_dir in $( ls "$(pwd)/src/module_${module}/web_service/class"); do
 						if [ -d "$(pwd)/src/module_${module}/web_service/class/${class_dir}" ]; then
 							echo "---- Link module_${module}/${class_dir} ----"
-							if [ -f "src/vitis/vas/rest/class/${class_dir}" ]; then
-								rm src/vitis/vas/rest/class/${class_dir}
+							if ! [ -f "src/vitis/vas/rest/class/${class_dir}" ]; then
+								ln -rsf src/module_${module}/web_service/class/${class_dir} src/vitis/vas/rest/class/${class_dir}
 							fi
-							ln -rsf src/module_${module}/web_service/class/${class_dir} src/vitis/vas/rest/class/${class_dir}
 						fi
 					done
 				fi
-- 
GitLab