summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php40
1 files changed, 34 insertions, 6 deletions
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 */