Codebase list osrframework / 2a83a63 debian / patches / add-script-config-upgrade.patch
2a83a63

Tree @2a83a63 (Download .tar.gz)

add-script-config-upgrade.patch @2a83a63raw · history · blame

--- /dev/null
+++ b/osrframework/utils/upgrade_config.py
@@ -0,0 +1,12 @@
+# !/usr/bin/python
+
+import os
+import shutil
+
+import osrframework.utils.configuration as configuration
+
+if __name__ == "__main__":
+    if os.path.exists(configuration.getConfigPath()["appPath"]):
+        for confdir in ["default", "plugins", "server", "transforms"]:
+            shutil.rmtree(os.path.join(configuration.getConfigPath()["appPath"], confdir), True)
+    configuration.initialize_config_files()
--- a/osrframework/utils/configuration.py
+++ b/osrframework/utils/configuration.py
@@ -40,8 +40,10 @@ def initialize_config_files():
     for dirconf in ["default", "plugins", "server"]:
         shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf))
 
-    # Create directory data
-    os.mkdir(getConfigPath()["appPathData"])
+    # Create directory data if it doesn't exist (we keep it at the
+    # upgrade)
+    if not os.path.exists(getConfigPath()["appPathData"]):
+        os.mkdir(getConfigPath()["appPathData"])
 
     # Create directory Transforms before copy *.py files
     os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR)