From 0f0808da144c28704e370e27daefe59e53bf269b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 24 Oct 2017 11:28:00 +0100 Subject: [PATCH] etc/dbq/zz-sqlite.php --- etc/dbq.php | 22 ---------------- etc/dbq/000-local.php | 7 ----- etc/dbq/zz-sqlite.php | 61 ++++++++++++++++++++++++++----------------- 3 files changed, 37 insertions(+), 53 deletions(-) diff --git a/etc/dbq.php b/etc/dbq.php index be99660a..48ec9b89 100644 --- a/etc/dbq.php +++ b/etc/dbq.php @@ -1,30 +1,8 @@ diff --git a/etc/dbq/000-local.php b/etc/dbq/000-local.php index 71b99f8d..d7c24a75 100644 --- a/etc/dbq/000-local.php +++ b/etc/dbq/000-local.php @@ -2,14 +2,7 @@ # # !!! MANDATORY !!! # -# NB 12.12.16 if (true or !nb::is_vm()) $DBQ = [ -# NB 29.11.16 'shell' => [ -# NB 29.11.16 'type' => 'sqlite', -# NB 29.11.16 'name' => 'shell', -# NB 29.11.16 'default_table' => 'shell_function', -# NB 29.11.16 'host' => nb::ROOT_DIR.'/share/db/shell.db', -# NB 29.11.16 ], 'nb-sys' => [ 'type' => 'sqlite', 'name' => 'Sys', diff --git a/etc/dbq/zz-sqlite.php b/etc/dbq/zz-sqlite.php index a1bdc744..cec1d33e 100644 --- a/etc/dbq/zz-sqlite.php +++ b/etc/dbq/zz-sqlite.php @@ -2,35 +2,48 @@ # # 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); ?> -- 2.47.3