Browse Source

init: Do not fail if directory exists (observed in a case of race condition)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73519 15284696-431f-4ddb-bdfa-cd5b030d7da7
Maris Nartiss 6 years ago
parent
commit
f846be7dd0
1 changed files with 8 additions and 1 deletions
  1. 8 1
      lib/init/grass.py

+ 8 - 1
lib/init/grass.py

@@ -435,7 +435,14 @@ def get_grass_config_dir():
         grass_config_dirname = ".grass7"
         directory = os.path.join(os.getenv('HOME'), grass_config_dirname)
     if not os.path.exists(directory):
-        os.mkdir(directory)
+        try:
+            os.mkdir(directory)
+        except OSError as e:
+            # Can happen as a race condition
+            if not e.errno == 17:
+                fatal(
+                    _("Failed to create configuration directory '%s' with error: %s")
+                    % (directory, e.strerror))
     return directory