]> git.openstreetmap.org Git - nominatim.git/commitdiff
make setup.php fail early on missing osm-file
authorsprengm <sprengm@ethz.ch>
Fri, 24 Aug 2012 15:55:19 +0000 (17:55 +0200)
committersprengm <sprengm@ethz.ch>
Sat, 25 Aug 2012 08:00:46 +0000 (10:00 +0200)
make setup.php fail early if:
  - no osm-file argument was supplied for --all or --import-data
  - the supplied osm-file is not existing or not readable (file permissions)

utils/setup.php

index 049ef860d2a9b933a9facee787e3ec92dc6be3a2..1db725c466f23b8c826069d2a662cc021ea9d5a6 100755 (executable)
 
        $bDidSomething = false;
 
+       // Check if osm-file is set and points to a valid file if --all or --import-data is given
+       if ($aCMDResult['import-data'] || $aCMDResult['all'])
+       {
+               if (!isset($aCMDResult['osm-file']))
+               {
+                       fail('missing --osm-file for data import');
+               }
+
+               if (!file_exists($aCMDResult['osm-file']))
+               {
+                       fail('the path supplied to --osm-file does not exist');
+               }
+
+               if (!is_readable($aCMDResult['osm-file']))
+               {
+                       fail('osm-file "'.$aCMDResult['osm-file'].'" not readable');
+               }
+       }
+
+
        // This is a pretty hard core default - the number of processors in the box - 1
        $iInstances = isset($aCMDResult['threads'])?$aCMDResult['threads']:(getProcessorCount()-1);
        if ($iInstances < 1)
                passthru('createdb -E UTF-8 '.$aDSNInfo['database']);
        }
 
-       if ($aCMDResult['create-db'] || $aCMDResult['all'])
+       if ($aCMDResult['setup-db'] || $aCMDResult['all'])
        {
-               echo "Create DB (2)\n";
+               echo "Setup DB\n";
                $bDidSomething = true;
                // TODO: path detection, detection memory, etc.