From 5db300f0be8a83889f44cf6cabcf439e2f109223 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 1 Jun 2012 16:42:12 +0200
Subject: [PATCH] Simplify empty file creation.

---
 slapos/recipe/agent/__init__.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/slapos/recipe/agent/__init__.py b/slapos/recipe/agent/__init__.py
index b728e2a19..8e8b7c892 100644
--- a/slapos/recipe/agent/__init__.py
+++ b/slapos/recipe/agent/__init__.py
@@ -73,11 +73,9 @@ class Recipe(BaseSlapRecipe, GenericSlapRecipe):
     configuration.set("agent", "software_list",
         parameter_dict["software_list"])
     configuration.set("agent", "log_directory", self.options["log_directory"])
-    configuration.set("agent", "state_file", self.options["state_file"])
-    if not os.path.exists(self.options["state_file"]):
-      state = open(self.options["state_file"], "w")
-      state.write('')
-      state.close()
+    state_file = self.options["state_file"]
+    configuration.set("agent", "state_file", state_file)
+    open(state_file, "a").close()
     configuration.set("agent", "path_file", self.options["path_file"])
     configuration.add_section("software_uri")
     software_list = json.loads(parameter_dict["software_list"])
-- 
2.30.9