diff --git a/Yuba.php b/Yuba.php old mode 100644 new mode 100755 index 7ed32e0..e99d531 --- a/Yuba.php +++ b/Yuba.php @@ -3,7 +3,7 @@ // Yuba // // ////////////////////////////////////////// -$version = "0.7.3"; +$version = "0.7.4"; ini_set('memory_limit', '4096M'); date_default_timezone_set("America/Los_Angeles"); @@ -312,7 +312,7 @@ $files = new RecursiveIteratorIterator( // Tally ////////////////////////////////////////// -echo "Tally\n"; +echo "Counting files...\n"; foreach ($files as $null) { } $first_run = 0; @@ -322,45 +322,7 @@ if (!$passed_total) { die; } -// Permissions & Stat -////////////////////////////////////////// - -echo ProgressBar::start($passed_total,"Stat"); - -$i = 0; -$noread = array(); -foreach ($files as $splFileInfo) { - - $shellpath = escapeshellarg($splFileInfo->getPathname()); - $realpath = $splFileInfo->getRealPath(); - - if ($splFileInfo->getType() != "link") { - $stx[$i] = array( $splFileInfo->getATime(), - $splFileInfo->getMTime(), - $splFileInfo->getCTime() ); - } - $sty[$i] = chop(shell_exec("stat -x ".$shellpath." 2>&1")); - - if ($realpath && !is_readable($realpath)) { - $noread[] = $realpath; - } - - echo ProgressBar::next(); - $i++; - - } - -if (count($noread)) { - foreach ($noread as $file) { - echo "Current user (".posix_getuid().") does not have read access to ".$file."\n"; - } - if ($p['readability']) { - echo "Exiting..."; - die; - } - } - -echo ProgressBar::finish(); +echo "Total files: ".$passed_total."\n"; // Pool DB ////////////////////////////////////////// @@ -376,15 +338,20 @@ $dbp->exec("CREATE TABLE IF NOT EXISTS contents (fid TEXT, created INTEGER, rela // Prescan ////////////////////////////////////////// +$i = 0; $family = array(); +$fids = array(); +$noread = array(); echo ProgressBar::start($passed_total,"Prescan"); foreach ($files as $splFileInfo) { - $pathname = $splFileInfo->getPathname(); $path = $splFileInfo->getPath(); - + $pathname = $splFileInfo->getPathname(); + $shellpath = escapeshellarg($splFileInfo->getPathname()); + $realpath = $splFileInfo->getRealPath(); + $key = md5($pathname); $pkey = md5($path); @@ -405,20 +372,51 @@ foreach ($files as $splFileInfo) { } - // Parents + // Cache stat values in stx array + + if ($splFileInfo->getType() != "link") { + $stx[$i] = array( $splFileInfo->getATime(), + $splFileInfo->getMTime(), + $splFileInfo->getCTime() ); + } - //$family[$key]['parents'] = getParents($zpath, $pathname); + if ($p['bypass_stat']) { + $sty[$i] = "bypass"; + } else { + $sty[$i] = chop(shell_exec("stat -x ".$shellpath." 2>&1")); + } + // Check file can be read + + if ($realpath && !is_readable($realpath)) { + $noread[] = $realpath; + } + // Children - $family[$pkey]['children'][] = $key; + //$family[$pkey]['children'][] = $key; + $family[$pkey]['children'][] = $i+1; echo ProgressBar::next(); + $i++; } echo ProgressBar::finish(); +// Thow permissions error + +if (count($noread)) { + "Current user (".posix_getuid().") does not have read access to the following files:"; + foreach ($noread as $file) { + echo $file."\n"; + } + if ($p['readability']) { + echo "Exiting..."; + die; + } + } + // Debug record of duplicate FIDs $dupes = array_filter($dx, function($a) { return count($a) > 1; }); @@ -568,7 +566,7 @@ if ($p['thumbs']) { if ($p['meta']) { - echo ProgressBar::start(count($fx),"Collecting external metadata"); + echo ProgressBar::start(count($fx),"Collecting external metadata..."); foreach ($fx as $array) { @@ -576,12 +574,11 @@ if ($p['meta']) { $pathname = $array[1]; $shellpath = escapeshellarg($pathname); $ext = pathinfo($pathname,PATHINFO_EXTENSION); + $found = 1; if (!in_array($ext, $e_files) && !in_array($ext, $m_files)) { echo ProgressBar::next("Not a media file: ".shortlabel($pathname)); continue; - } else { - echo ProgressBar::next("Metadata: ".shortlabel($pathname)); } if (in_array($ext, $e_files)) { @@ -592,6 +589,7 @@ if ($p['meta']) { $stmt->BindValue(":fid",$fid); $stmt->BindValue(":tags",serialize($rawexif[0])); $stmt->execute(); + $found = 0; } } @@ -603,8 +601,15 @@ if ($p['meta']) { //$stmt->BindValue(":info",serialize(parseMediaInfo(shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1")))); $stmt->BindValue(":info",shell_exec($bin_mediainfo." --Output=OLDXML ".$shellpath." 2>&1")); $stmt->execute(); + $found = 0; } } + + if ($found) { + echo ProgressBar::next("Metadata found: ".shortlabel($pathname)); + } else { + echo ProgressBar::next("Collecting metadata: ".shortlabel($pathname)); + } } @@ -971,7 +976,7 @@ foreach ($files as $splFileInfo) { // Double check stat for file against pre-run value - if ($type != "link") { + if ($p['verify_stat'] && $type != "link") { $pre_access = $pre_modify = $pre_change = null; $post_access = $post_modify = $post_change = null; diff --git a/functions.php b/functions.php old mode 100644 new mode 100755 diff --git a/web/lib/debug.php b/web/lib/debug.php new file mode 100644 index 0000000..4597274 --- /dev/null +++ b/web/lib/debug.php @@ -0,0 +1,451 @@ +\n"; + $charset = true; + } + if ($level>$limit) + { + if ($plain) + { + return str_repeat(' ', 4*$level)."...\n"; + } + else + { + return "..."; + } + } + if (is_object($object) || (is_array($object) && count($object)>0)) + { + foreach ($object as $key => $value) + { + if ($plain) + { + $result .= str_repeat(' ', 4*$level).$key; + } + else + { + if (is_array($object)) + { + $result .= "".$key.''; + } + else + { + $result .= ''.$key.''; + } + } + if (is_object($value) || (is_array($value) && count($value)>0)) + { + if (is_object($value)) + { + if ($plain) + { + $result .= " (".get_class($value).")"; + } + else + { + $result .= " ".get_class($value).""; + } + } + else + { + if ($plain) + { + $result .= " (array)"; + } + else + { + $result .= " array"; + } + } + if ($plain) + { + $result .= "\n"; + } + else + { + $collapse = !($level+1<=1 || $title===true || (is_string($title) && substr($title,0,1)=='*')); + $collapse = false; // hack + $result .= "\n