issue107, make sqlite-temp directory configurable
authorAndreas Unterkircher <unki@netshadow.at>
Sat, 29 Mar 2008 07:26:34 +0000 (08:26 +0100)
committerAndreas Unterkircher <unki@netshadow.at>
Sat, 29 Mar 2008 07:33:45 +0000 (08:33 +0100)
issue107, add a note to CHANGE about issue107 (configurable sqlite temp directory)

Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
CHANGELOG
phpfspot.class.php
phpfspot_cfg.php.dist

index 5e1d438bed5143e5b6befc6023af059c990dcde4..9cf51cb2592d66167236a9840b04561f7c0e0a9f 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ phpfspot (1.4)
   * feature, support PNG image format.
   * feature, auto-completion for tag-search.
   * feature, lightbox2 for photo preview out of the photo index.
+  * bug, SQlite temporary directory can now be set in phpfspot_cfg.php
 
  -- Andreas Unterkircher <unki@netshadow.at>  Sat, 29 Mar 2008 11:00:00 +0100
 
index cfa92576ce55b9c12f6466e08c3b5e251f379af4..a9e3e686ea3e52fa682d6792de91ba8cdfaf9c12 100644 (file)
@@ -70,19 +70,27 @@ class PHPFSPOT {
          exit(1);
       }
 
-      $this->db  = new PHPFSPOT_DB($this, $this->cfg->fspot_db);
+      /******* Opening F-Spot's sqlite database *********/
+
+      /* Check if database file is writeable */
       if(!is_writeable($this->cfg->fspot_db)) {
          print $this->cfg->fspot_db ." is not writeable for user ". $this->getuid() ."\n";
          exit(1);
       }
 
-      $this->dbver = $this->getFspotDBVersion();
+      /* open the database */
+      $this->db  = new PHPFSPOT_DB($this, $this->cfg->fspot_db);
 
-      if(!is_writeable(dirname($this->cfg->phpfspot_db))) {
-         print dirname($this->cfg->phpfspot_db) .": directory is not writeable for user ". $this->getuid() ."\n";
-         exit(1);
+      /* change sqlite temp directory, if requested */
+      if(isset($this->cfg->sqlite_temp_dir)) {
+         $this->db->db_exec("
+            PRAGMA
+               temp_store_directory = '". $this->cfg->sqlite_temp_dir ."'
+         ");
       }
 
+      $this->dbver = $this->getFspotDBVersion();
+
       if(!is_writeable($this->cfg->base_path ."/templates_c")) {
          print $this->cfg->base_path ."/templates_c: directory is not writeable for user ". $this->getuid() ."\n";
          exit(1);
@@ -93,12 +101,32 @@ class PHPFSPOT {
          exit(1);
       }
 
-      $this->cfg_db = new PHPFSPOT_DB($this, $this->cfg->phpfspot_db);
+      /******* Opening phpfspot's sqlite database *********/
+
+      /* Check if directory where the database file is stored is writeable  */
+      if(!is_writeable(dirname($this->cfg->phpfspot_db))) {
+         print dirname($this->cfg->phpfspot_db) .": directory is not writeable for user ". $this->getuid() ."\n";
+         exit(1);
+      }
+
+      /* Check if database file is writeable */
       if(!is_writeable($this->cfg->phpfspot_db)) {
          print $this->cfg->phpfspot_db ." is not writeable for user ". $this->getuid() ."\n";
          exit(1);
       }
 
+      /* open the database */
+      $this->cfg_db = new PHPFSPOT_DB($this, $this->cfg->phpfspot_db);
+
+      /* change sqlite temp directory, if requested */
+      if(isset($this->cfg->sqlite_temp_dir)) {
+         $this->cfg_db->db_exec("
+            PRAGMA
+               temp_store_directory = '". $this->cfg->sqlite_temp_dir ."'
+         ");
+      }
+
+      /* Check if some tables need to be created */
       $this->check_config_table();
 
       /* include Smarty template engine */
index f002aebc14984c334d25fe31fc56222305cc153e..75b54ad8db1b42a0ae42d69b5414eb6298926ed4 100644 (file)
@@ -56,6 +56,15 @@ class PHPFSPOT_CFG {
    */
    var $phpfspot_db = "/var/www/f-spot-dbs/phpfspot.db";
 
+   /* sqlite temp dir. per default sqlite tries /var/tmp, /usr/tmp, /tmp
+      and the current working directory for creating temporary files.
+      If you still get error messages when phpfspot tries to create the
+      indecies in $fspot_db, set this option to another writeable
+      directory. For example $phpfspot_db directory, which must be
+      writeable anyway.
+   */
+   // var $sqlite_temp_dir = "/var/www/f-spot-dbs";
+
    /* don't touch if you haven't changed the base templates */
    var $thumb_width = "150";
    var $thumb_height = "145";