#
# Create *-sqlite databases
#
-if (empty($DIR_SQLITE)) return;
-
$host_already_exists = [];
-foreach ($DBQ as $id => $db) {
- if (1
- and !empty($db['type']) and $db['type'] == 'sqlite'
- and !empty($db['host'])
- ) $host_already_exists[$db['host']] = $id;
-}
-foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
+foreach ([
+ '/home/nico/ownCloud',
+ '/Users/nico/ownCloud',
+ '/home/nico/Dropbox',
+ '/Users/nico/Dropbox',
+ '', # / !!!
+] as $DIR_SQLITE) {
+ if (!is_readable($DIR_SQLITE.'/var/lib/sqlite')) continue;
+ $DIR_SQLITE .= '/var/lib/sqlite';
+
+ foreach ($DBQ as $id => $db) {
+ if (1
+ and !empty($db['type']) and $db['type'] == 'sqlite'
+ and !empty($db['host'])
+ ) $host_already_exists[$db['host']] = $id;
+ }
+
+ foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
+
+ if (strpos($file,'_conflict-')) continue;
- if (strpos($file,'_conflict-')) continue;
+ if (isset($host_already_exists["$DIR_SQLITE/$file"])) {
+ $DBQ[$host_already_exists["$DIR_SQLITE/$file"]]['sql_pre'][] = 'PRAGMA journal_mode=OFF';
+ continue;
+ }
- if (isset($host_already_exists["$DIR_SQLITE/$file"])) {
- $DBQ[$host_already_exists["$DIR_SQLITE/$file"]]['sql_pre'][] = 'PRAGMA journal_mode=OFF';
- continue;
+ $name = basename($file,'.db');
+ $id = "${name}-sqlite";
+
+ if (!isset($DBQ[$id])) $DBQ[$id] = [
+ 'host' => "$DIR_SQLITE/$file",
+ 'type' => 'sqlite',
+ #'title' => 'created by dbq.php',
+ 'title' => Db::prettyText($name),
+ '_import' => $name
+ ];
+ #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]);
}
- $name = basename($file,'.db');
- $id = "${name}-sqlite";
-
- if (!isset($DBQ[$id])) $DBQ[$id] = [
- 'host' => "$DIR_SQLITE/$file",
- 'type' => 'sqlite',
- #'title' => 'created by dbq.php',
- 'title' => Db::prettyText($name),
- '_import' => $name
- ];
- #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]);
}
+
+unset($DIR_SQLITE,$host_already_exists);
?>