This commit is contained in:
2018-09-03 03:40:31 -07:00
parent 489ff7cd70
commit bae448657b
5 changed files with 647 additions and 179 deletions

105
Yuba.php Normal file → Executable file
View File

@@ -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;