PLD-doc: PLD_www_res/buildlogs.sql/migration.php, PLD_www_res/buil...

witekfl witekfl at pld-linux.org
Sun Dec 2 16:49:48 CET 2007


Author: witekfl                      Date: Sun Dec  2 15:49:48 2007 GMT
Module: PLD-doc                       Tag: HEAD
---- Log message:
- you don't have to delete the buildlogs.db before starting
  the migration.php. The migration.php do it itself.
- the migration.php is faster

---- Files affected:
PLD-doc/PLD_www_res/buildlogs.sql:
   migration.php (1.5 -> 1.6) , buildlogs.inc (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: PLD-doc/PLD_www_res/buildlogs.sql/migration.php
diff -u PLD-doc/PLD_www_res/buildlogs.sql/migration.php:1.5 PLD-doc/PLD_www_res/buildlogs.sql/migration.php:1.6
--- PLD-doc/PLD_www_res/buildlogs.sql/migration.php:1.5	Fri Nov 30 12:17:30 2007
+++ PLD-doc/PLD_www_res/buildlogs.sql/migration.php	Sun Dec  2 16:49:42 2007
@@ -29,6 +29,10 @@
 */
 include('buildlogs.inc');
 
+if (file_exists($database_file)) {
+	unlink($database_file);
+}
+
 $query = " CREATE TABLE LOGS(log_id INTEGER PRIMARY KEY, arch_id INTEGER, result INTEGER, size INTEGER, mtime INTEGER, spec TEXT);";
 try {
 	$dbhandle = new PDO("$database");
@@ -36,29 +40,26 @@
 	die("new PDO: ". $e->getMessage());
 }
 
-$result = array("FAIL" => 0, "OK" => 1);
-
-$list1 = `find $root_directory/th $root_directory/ac -name '*.bz2'`;
-$lista = explode("\n", rtrim($list1));
-$list1 = '';
-foreach ($lista as $file) {
-	preg_match("|$root_directory/(.*/.*)/(.*)/(.*)\.bz2|", $file, $matches);
-
-	$arch_name = $matches[1];
-	if (!array_key_exists($arch_name, $reverse_addr)) continue;
-	else $arch_id = $reverse_addr[$arch_name];
+$result = array("FAIL", "OK");
 
-	$result_name = $matches[2];
-	if (!array_key_exists($result_name, $result)) continue;
-	else $result_id = $result[$result_name];
-
-	$spec_name = $matches[3];
-	if ($spec_name == '') continue;
-
-	$size = filesize($file);
-	$mtime = filemtime($file);
-	$query .= " INSERT INTO LOGS(arch_id, result, size, mtime, spec) VALUES ($arch_id, $result_id, $size, $mtime, '$spec_name');";
+for ($i = 1; $i < count($addr); $i++) {
+	for ($ok = 0; $ok < 2; $ok++) {
+		$dir = "$root_directory/" . $addr[$i] . "/" . $result[$ok];
+		$dh = opendir($dir);
+		if (!$dh) continue;
+		while ($file = readdir($dh)) {
+			if (preg_match("/^(.*)\.bz2$/", $file, $match)) {
+				$f = "$dir/$file";
+				$size = filesize($f);
+				$mtime = filemtime($f);
+				$spec = $match[1];
+				$query .= " INSERT INTO logs(arch_id, result, size, mtime, spec) VALUES($i, $ok, $size, $mtime, '$spec');";
+			}
+		}
+		closedir($dh);
+	}
 }
+
 $dbhandle->beginTransaction();
 $dbhandle->exec("$query");
 $dbhandle->commit();

================================================================
Index: PLD-doc/PLD_www_res/buildlogs.sql/buildlogs.inc
diff -u PLD-doc/PLD_www_res/buildlogs.sql/buildlogs.inc:1.4 PLD-doc/PLD_www_res/buildlogs.sql/buildlogs.inc:1.5
--- PLD-doc/PLD_www_res/buildlogs.sql/buildlogs.inc:1.4	Fri Nov 30 12:17:30 2007
+++ PLD-doc/PLD_www_res/buildlogs.sql/buildlogs.inc	Sun Dec  2 16:49:43 2007
@@ -1,5 +1,6 @@
 <?php
-$database = 'sqlite:/home/services/httpd/html/pld-buildlogs/db/buildlogs.db';
+$database_file = "/home/services/httpd/html/pld-buildlogs/db/buildlogs.db";
+$database = "sqlite:$database_file";
 $root_directory = "/home/services/ftp/pub/pld-buildlogs";
 $addr = array(
 	0 => "", /* must be first */
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/PLD-doc/PLD_www_res/buildlogs.sql/migration.php?r1=1.5&r2=1.6&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/PLD-doc/PLD_www_res/buildlogs.sql/buildlogs.inc?r1=1.4&r2=1.5&f=u



More information about the pld-cvs-commit mailing list