From 1532cb592eb45670d0d72fe5e9acb1f5b0fb31c9 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 29 Mar 2008 08:26:34 +0100 Subject: issue107, make sqlite-temp directory configurable issue107, add a note to CHANGE about issue107 (configurable sqlite temp directory) Signed-off-by: Andreas Unterkircher --- CHANGELOG | 1 + phpfspot.class.php | 40 ++++++++++++++++++++++++++++++++++------ phpfspot_cfg.php.dist | 9 +++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5e1d438..9cf51cb 100644 --- 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 Sat, 29 Mar 2008 11:00:00 +0100 diff --git a/phpfspot.class.php b/phpfspot.class.php index cfa9257..a9e3e68 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -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 */ diff --git a/phpfspot_cfg.php.dist b/phpfspot_cfg.php.dist index f002aeb..75b54ad 100644 --- a/phpfspot_cfg.php.dist +++ b/phpfspot_cfg.php.dist @@ -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"; -- cgit v1.2.3-18-g5258