From 634773fcf69c503fe8689447f52a51882e260b96 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob.mottram@codethink.co.uk>
Date: Wed, 29 Jun 2016 16:48:19 +0100
Subject: [PATCH] Only record the new commit if all goes well

---
 src/freedombone | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/freedombone b/src/freedombone
index 9353d311a..89f200c5a 100755
--- a/src/freedombone
+++ b/src/freedombone
@@ -1668,7 +1668,6 @@ function set_repo_commit {
 			if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
 				cd $repo_dir
 				git_pull $repo_url $repo_commit
-				sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
 
 				# application specific stuff after updating the repo
 				if [[ $repo_dir == *"www"* ]]; then
@@ -1743,6 +1742,8 @@ function set_repo_commit {
 					systemctl restart ipfs
 					systemctl daemon-reload
 				fi
+
+				sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
 			fi
 		else
 			echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
-- 
GitLab