From 3816d326ac6ad5855c8dd7ed044724960967429b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 20 Jan 2017 00:47:28 +0000 Subject: [PATCH] delete etc/dbq/PERSO --- etc/dbq.php | 10 +++++++--- etc/dbq/zz-sqlite.php | 36 ++++++++++++++++++++++++++++++++++++ etc/dbq/zzz-all.php | 33 --------------------------------- 3 files changed, 43 insertions(+), 36 deletions(-) create mode 100644 etc/dbq/zz-sqlite.php diff --git a/etc/dbq.php b/etc/dbq.php index 8504ae6b..be99660a 100644 --- a/etc/dbq.php +++ b/etc/dbq.php @@ -13,14 +13,18 @@ foreach ([ '/Users/nico/ownCloud', '/home/nico/Dropbox', '/Users/nico/Dropbox', + '', # / !!! ] as $DIR_SQLITE) { - if (is_readable($DIR_SQLITE)) { + + if (is_readable($DIR_SQLITE.'/var/lib/sqlite')) { + $DIR_SQLITE .= '/var/lib/sqlite'; break; + } else { unset($DIR_SQLITE); + } + } -if (!empty($DIR_SQLITE)) $DIR_SQLITE .= '/var/lib/sqlite'; -elseif (file_exists('/var/lib/sqlite')) $DIR_SQLITE = '/var/lib/sqlite'; ?> diff --git a/etc/dbq/zz-sqlite.php b/etc/dbq/zz-sqlite.php new file mode 100644 index 00000000..a1bdc744 --- /dev/null +++ b/etc/dbq/zz-sqlite.php @@ -0,0 +1,36 @@ + $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 (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]); +} +?> diff --git a/etc/dbq/zzz-all.php b/etc/dbq/zzz-all.php index 18e4da1f..21bd9654 100644 --- a/etc/dbq/zzz-all.php +++ b/etc/dbq/zzz-all.php @@ -1,37 +1,4 @@ $db) { - if (1 - and !empty($db['type']) and $db['type'] == 'sqlite' - and !empty($db['host']) - ) $host_already_exists[$db['host']] = $id; -} - -if (!empty($DIR_SQLITE)) { - foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) { - - 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; - } - - $name = basename($file,'.db'); - $id = "$name-sqlite"; - - $DBQ[$id] = [ - 'host' => "$DIR_SQLITE/$file", - 'type' => 'sqlite', - 'title' => 'created by dbq.php', - '_import' => $name - ]; - #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]); - } -} # # ALL - Attach all sqlite databases -- 2.47.3