From 308d3c513a3d7fb0f84c8d480efa5760072eafbe Mon Sep 17 00:00:00 2001 From: profiteroles Date: Wed, 12 Jun 2019 23:26:54 -0700 Subject: [PATCH] Debug output tweak --- Yuba.php | 58 +++++++++++++++++++++++++-------------------------- functions.php | 9 ++++++-- helper.php | 2 +- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Yuba.php b/Yuba.php index f9bcc38..90de0f1 100755 --- a/Yuba.php +++ b/Yuba.php @@ -26,6 +26,7 @@ require("filetypes.php"); $wopt_steps = 12; $wopt_currstep = 1; +$wopt_clear = 0; $parser = new plistParser(); @@ -462,7 +463,7 @@ foreach ($files as $splFileInfo) { } -echo ProgressBar::finish(); +echo ProgressBar::finish($wopt_clear); // Thow permissions error @@ -476,13 +477,28 @@ if (count($noread)) { // Write family to DB +$dupes = array_filter($dx, function($a) { return count($a) > 1; }); +$dupecount = 0; +$dupetotal = 0; + +if (count($dupes)) { + $dupecount = count($dupes,COUNT_RECURSIVE) - count($dupes); + $dupetotal = floor(($dupecount/$passed_total)*100); + foreach ($dupes as $fid => $array) { + $stmt = $dbo->prepare("INSERT INTO dupes VALUES (:fid, :array)"); + $stmt->BindValue(":fid",$fid); + $stmt->BindValue(":array",serialize($array)); + $stmt->execute(); + } + } + $message = "Writing family to DB: "; $message .= $passed_file." files, "; $message .= $passed_dir." dirs, "; $message .= $nodescended." bundles, "; $message .= $passed_link." links, "; $message .= $ignored." ignored, "; -//$message .= (@$dupecount ? $dupecount : 0)." dupes"; +$message .= $dupecount." dupes (".$dupetotal."%)"; echo ProgressBar::start(count($family),$message); @@ -502,23 +518,7 @@ foreach ($family as $key => $item) { } -// Dupes - -$dupes = array_filter($dx, function($a) { return count($a) > 1; }); - -if (count($dupes)) { - $dupecount = count($dupes,COUNT_RECURSIVE) - count($dupes); - $dupetotal = floor(($dupecount/$passed_total)*100); - echo ProgressBar::next("Recording dupes (".$dupetotal."%)"); - foreach ($dupes as $fid => $array) { - $stmt = $dbo->prepare("INSERT INTO dupes VALUES (:fid, :array)"); - $stmt->BindValue(":fid",$fid); - $stmt->BindValue(":array",serialize($array)); - $stmt->execute(); - } - } - -echo ProgressBar::finish(); +echo ProgressBar::finish($wopt_clear); // create an index for family db $dbo->exec("CREATE INDEX family_index ON family (pid)"); @@ -551,7 +551,7 @@ foreach ($fx as $array) { } echo ProgressBar::next(); } -echo ProgressBar::finish(); +echo ProgressBar::finish($wopt_clear); // Icons Test ////////////////////////////////////////// @@ -576,13 +576,13 @@ if ($p['icons']) { } file_put_contents($batchfile,implode("\n", $line)); - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); echo ProgressBar::start($passed_file,"Running icon batch (".stepString().")"); passthru($bin_parallel." < ".$batchfile); - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); } @@ -712,7 +712,7 @@ if ($p['thumbs']) { } - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); } @@ -760,7 +760,7 @@ if ($p['contents']) { echo ProgressBar::next(true); } - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); } @@ -822,7 +822,7 @@ if ($p['meta']) { } - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); } @@ -858,7 +858,7 @@ if ($p['hash']) { } } - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); } @@ -968,7 +968,7 @@ if ($p['spotlight']) { } - echo ProgressBar::finish(); + echo ProgressBar::finish($wopt_clear); } @@ -1197,7 +1197,7 @@ foreach ($files as $splFileInfo) { } -echo ProgressBar::finish(); +echo ProgressBar::finish($wopt_clear); // Milk ////////////////////////////////////////// @@ -1349,7 +1349,7 @@ while ($row_a = $loop->fetch()) { } -echo ProgressBar::finish(); +echo ProgressBar::finish($wopt_clear); // Cleanup ////////////////////////////////////////// diff --git a/functions.php b/functions.php index 762308f..ef43b7e 100755 --- a/functions.php +++ b/functions.php @@ -59,11 +59,16 @@ class ProgressBar { return self::display($message); } - public static function finish() { + public static function finish($clear = null) { global $wopt_currstep; $wopt_currstep++; self::$done = 0; - return "\nREFRESH\n"; + if ($clear) { + return "\nREFRESH\n"; + } else { + return "\n".str_repeat("*",99)."\n"; + } + } } diff --git a/helper.php b/helper.php index 0e1a601..ead6e4f 100755 --- a/helper.php +++ b/helper.php @@ -45,7 +45,7 @@ switch ($mode) { $stmt->BindValue(":tool",$row['tool']); } else { $dfile = $bpath."/icons/".substr($hash, 0, 2)."/".$hash.".png"; - if (!is_dir(dirname($dfile))) { mkdir(dirname($dfile)); } + if (!is_dir(dirname($dfile))) { @mkdir(dirname($dfile)); } shell_exec("sips -z ".$p['thumb_size']." ".$p['thumb_size']." ".$tfile." --out ".$dfile); $stmt->BindValue(":created",time()); $stmt->BindValue(":relative_path",substr($dfile,strlen($bpath)));