]> git.nbdom.net Git - nb.git/commitdiff
delete etc/dbq/PERSO
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 20 Jan 2017 00:47:28 +0000 (00:47 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 20 Jan 2017 00:47:28 +0000 (00:47 +0000)
etc/dbq.php
etc/dbq/zz-sqlite.php [new file with mode: 0644]
etc/dbq/zzz-all.php

index 8504ae6b5c100e035ceef89a65eea2925a0bd65a..be99660aaf90c537e6042c2a936e58f631afa300 100644 (file)
@@ -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 (file)
index 0000000..a1bdc74
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+#
+# 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) {
+
+  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]);
+}
+?>
index 18e4da1f55cda2573a2c45e108eca16d18bcdc68..21bd96545e29011d26333903a36f20026f636768 100644 (file)
@@ -1,37 +1,4 @@
 <?php
-#
-# Create *-sqlite databases
-#
-$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;
-}
-
-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