Showing 1 changed files with 14 additions and 9 deletions
+14 -9
flightgear/fgaddon
... ...
@@ -387,16 +387,21 @@ if test -e $database; then
387 387
         exit 1
388 388
     fi
389 389
     if sqlite_request '.tables' | grep -q 'recover_'; then
390
-        echo "recovering from previous saved state"
391 390
         hangar[id]=$(sqlite_request "select hangar from recover_aircrafts limit 1")
392
-        eval $(sqlite_request "select printf('hangar[name]=%s;hangar[url]=%s;hangar[type]=%s;hangar[source]=%s',
393
-                                              name,           url,           type,           source)
394
-                               from hangars
395
-                               where id = '${hangar[id]}'")
396
-        source $(grep -l "^\s*hangar\[name\]=${hangar[name]}\s*$" ${0%*/}.d/*.hangar)
397
-        eval "getfromrepo () {$(declare -f getfromrepo | sed '1,2d;$d'); xmlremovecomments;}"
398
-        apply_revision
399
-        exit
391
+        if test -n "${hangar[id]}"; then
392
+            echo "recovering from previous saved state"
393
+            eval $(sqlite_request "select printf('hangar[name]=%s;hangar[url]=%s;hangar[type]=%s;hangar[source]=%s',
394
+                                                  name,           url,           type,           source)
395
+                                   from hangars
396
+                                   where id = '${hangar[id]}'")
397
+            source $(grep -l "^\s*hangar\[name\]=${hangar[name]}\s*$" ${0%*/}.d/*.hangar)
398
+            eval "getfromrepo () {$(declare -f getfromrepo | sed '1,2d;$d'); xmlremovecomments;}"
399
+            apply_revision
400
+            exit
401
+        else
402
+            sqlite_request 'drop table recover_aircrafts'
403
+            sqlite_request 'drop table recover_setxml'
404
+        fi
400 405
     fi
401 406
 fi
402 407