From 135299357b6ef4545f8de3c06cc4bf68ee89c3a1 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@brief.schottelius.org>
Date: Fri, 21 Sep 2012 11:08:55 +0200
Subject: [PATCH] correctly setup state

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
---
 conf/type/__directory/gencode-remote | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/conf/type/__directory/gencode-remote b/conf/type/__directory/gencode-remote
index 25553183..56bd73a1 100755
--- a/conf/type/__directory/gencode-remote
+++ b/conf/type/__directory/gencode-remote
@@ -18,12 +18,14 @@
 # along with cdist. If not, see <http://www.gnu.org/licenses/>.
 #
 
-destination="/$__object_id"
-state_should="$(cat "$__object/parameter/state")"
+# Check state and exit if nothing needs to be done
+state_should="present"
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
 state_is="$(cat "$__object/explorer/state")"
-
 [ "$state_should" = "$state_is" ] && exit 0
 
+destination="/$__object_id"
+
 mkdiropt=""
 grep yes "$__object/parameter/parents" >/dev/null 2>&1 && mkdiropt="-p"
 recursive=""