feed-browser: exit if database cannot be found or created
authorMarcin Juszkiewicz <hrw@openembedded.org>
Thu, 5 Jul 2007 15:37:56 +0000 (15:37 +0000)
committerMarcin Juszkiewicz <hrw@openembedded.org>
Thu, 5 Jul 2007 15:37:56 +0000 (15:37 +0000)
contrib/feed-browser/includes/functions.inc
contrib/feed-browser/index.php
contrib/feed-browser/update.php

index 5549aa5..ad8e57e 100644 (file)
@@ -422,8 +422,12 @@ function sectionslist()
 
 function check_database()
 {
-       if($db = sqlite_open(DB_FILENAME))
+       $db_exists = FALSE;
+
+       if(file_exists(DB_FILENAME) AND $db = sqlite_open(DB_FILENAME))
        {
+               $db_exists = TRUE;
+
                //initialize db
                if (db_table_exists ($db, 'packages') === FALSE)
                {  
@@ -461,6 +465,8 @@ function check_database()
 
                sqlite_close($db);
        }
+
+       return $db_exists;
 }
 
 
index afa4c1a..a6c9206 100644 (file)
 require_once 'includes/config.inc';
 require_once 'includes/functions.inc';
 
-check_database();
+if(!check_database())
+{
+       die("Database not found and cannot be created.");
+}
 
 $name = '';
 
index ed67d3b..387acf9 100644 (file)
@@ -37,7 +37,10 @@ require_once 'includes/functions.inc';
    Description: IPv4 link-local address allocator
  */
 
-check_database();
+if(!check_database())
+{
+       die("Database not found and cannot be created.");
+}
 
 $feeds = db_query("SELECT f_id, f_name, f_uri FROM feeds");