0.7.12.5 (Icons)
This commit is contained in:
74
Yuba.php
74
Yuba.php
@@ -7,6 +7,7 @@ $version = file_get_contents(__DIR__."/version.txt");
|
||||
|
||||
ini_set('memory_limit', '10240M');
|
||||
date_default_timezone_set("America/Los_Angeles");
|
||||
$mytime = time();
|
||||
|
||||
// Includes & Prefs
|
||||
//////////////////////////////////////////
|
||||
@@ -25,7 +26,7 @@ $p['phpbin'] = "/usr/bin/php";
|
||||
require("functions.php");
|
||||
require("filetypes.php");
|
||||
|
||||
$wopt_steps = 10;
|
||||
$wopt_steps = 12;
|
||||
$wopt_currstep = 1;
|
||||
|
||||
$parser = new plistParser();
|
||||
@@ -74,6 +75,7 @@ if (is_writable($zpath)) { echo "Warning: source is writeable\n"; }
|
||||
$bpath = chop($bdest,"/")."/".substr(crc32($zpath),0,3)."_".$blabel.".bundle";
|
||||
if (!is_dir($bpath)) { mkdir($bpath); }
|
||||
if (!is_dir($bpath."/thumbs")) { mkdir($bpath."/thumbs"); }
|
||||
if (!is_dir($bpath."/icons")) { mkdir($bpath."/icons"); }
|
||||
if (!is_dir($bpath."/contents")) { mkdir($bpath."/contents"); }
|
||||
|
||||
// Metadata tools
|
||||
@@ -86,6 +88,7 @@ $bin_qltool = __DIR__."/bin/qltool";
|
||||
$bin_magick = __DIR__."/bin/magick";
|
||||
$bin_sox = __DIR__."/bin/sox";
|
||||
$bin_pngcrush = __DIR__."/bin/pngcrush";
|
||||
$bin_parallel = __DIR__."/bin/parallel";
|
||||
$bin_vips = "vipsthumbnail";
|
||||
|
||||
// Logfile
|
||||
@@ -387,17 +390,19 @@ $dbp = new PDO("sqlite:".$bpath."/pool.sqlite3");
|
||||
|
||||
$dbp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$dbp->query("PRAGMA page_size = 4096");
|
||||
$dbp->query("PRAGMA cache_size = 10000");
|
||||
$dbp->query("PRAGMA locking_mode = EXCLUSIVE");
|
||||
$dbp->query("PRAGMA synchronous = NORMAL");
|
||||
$dbp->query("PRAGMA journal_mode = WAL");
|
||||
//$dbp->query("PRAGMA page_size = 4096");
|
||||
//$dbp->query("PRAGMA cache_size = 10000");
|
||||
//$dbp->query("PRAGMA locking_mode = EXCLUSIVE");
|
||||
//$dbp->query("PRAGMA synchronous = NORMAL");
|
||||
//$dbp->query("PRAGMA journal_mode = WAL");
|
||||
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS md5 (fid TEXT, hash TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS exiftool (fid TEXT, tags TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS mediainfo (fid TEXT, info TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS thumbs (fid TEXT, created INTEGER, relative_path TEXT, width INTEGER, height INTEGER, tool TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS icons (fid TEXT, hash TEXT, created INTEGER, relative_path TEXT, tool TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS contents (fid TEXT, created INTEGER, relative_path TEXT)");
|
||||
$dbp->exec("CREATE TABLE IF NOT EXISTS counter (time INTEGER, pass TEXT, count INTEGER)");
|
||||
|
||||
// Prescan
|
||||
//////////////////////////////////////////
|
||||
@@ -465,6 +470,9 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
}
|
||||
|
||||
// Convert $fx to splFixedArray for performance (?)
|
||||
//$fx = SplFixedArray::fromArray($fx);
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
// Thow permissions error
|
||||
@@ -540,13 +548,55 @@ $wopt_currstep++;
|
||||
//////////////////////////////////////////
|
||||
|
||||
echo ProgressBar::start(count($fx),"Searching for directory previews (".stepString().")");
|
||||
|
||||
foreach ($fx as $array) {
|
||||
$fid = $array[0];
|
||||
$pathname = $array[1];
|
||||
if (in_array(basename($pathname),$p['p_files'])) {
|
||||
$dpreview[dirname($pathname)] = $fid;
|
||||
}
|
||||
echo ProgressBar::next();
|
||||
}
|
||||
echo ProgressBar::finish();
|
||||
|
||||
// Icons Test
|
||||
//////////////////////////////////////////
|
||||
|
||||
$p['icons'] = 1;
|
||||
|
||||
if ($p['icons']) {
|
||||
|
||||
$stmt = $dbp->prepare("INSERT INTO counter VALUES (:time, :pass, :count)");
|
||||
$stmt->BindValue(":time",$mytime);
|
||||
$stmt->BindValue(":pass","icons");
|
||||
$stmt->BindValue(":count",0);
|
||||
$stmt->execute();
|
||||
|
||||
echo ProgressBar::start(count($fx),"Creating icon batch (".stepString().")");
|
||||
|
||||
if (!is_dir("/tmp/Yuba/")) { mkdir("/tmp/Yuba/"); }
|
||||
if (!is_dir("/tmp/Yuba/".$mytime)) { mkdir("/tmp/Yuba/".$mytime); }
|
||||
$batchfile = "/tmp/Yuba/".$mytime."/batch.sh";
|
||||
$helper = realpath("helper.php");
|
||||
|
||||
foreach ($fx as $array) {
|
||||
$fid = $array[0];
|
||||
$pathname = $array[1];
|
||||
$icmd = $p['phpbin']." ".$helper." icons ".$fid." ".escapeshellarg($pathname)." ".escapeshellarg($bpath)." ".$mytime;
|
||||
msg($icmd);
|
||||
$line[] = $icmd;
|
||||
echo ProgressBar::next();
|
||||
}
|
||||
file_put_contents($batchfile,implode("\n", $line));
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
echo ProgressBar::start(count($fx),"Running icon batch (".stepString().")");
|
||||
echo ProgressBar::next();
|
||||
|
||||
passthru($bin_parallel." < ".$batchfile);
|
||||
|
||||
echo ProgressBar::finish();
|
||||
|
||||
}
|
||||
|
||||
// Thumbnails
|
||||
@@ -825,6 +875,7 @@ $dbp->exec("CREATE INDEX IF NOT EXISTS exiftool_index ON exiftool (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS md5_index ON md5 (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS mediainfo_index ON mediainfo (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS thumbs_index ON thumbs (fid)");
|
||||
$dbp->exec("CREATE INDEX IF NOT EXISTS icons_index ON icons (fid)");
|
||||
|
||||
// Spotlight
|
||||
//////////////////////////////////////////
|
||||
@@ -1090,7 +1141,7 @@ foreach ($files as $splFileInfo) {
|
||||
|
||||
} elseif ($type == "dir") {
|
||||
|
||||
if (is_array($dpreview) && $dpreview[$pathname]) {
|
||||
if (@is_array($dpreview) && $dpreview[$pathname]) {
|
||||
$fetch_thumb = $dbp->query("SELECT * FROM thumbs WHERE fid='".$dpreview[$pathname]."'")->fetch();
|
||||
if (@$fetch_thumb['relative_path']) {
|
||||
$stmt->BindValue(":thumb_filename",$fetch_thumb['relative_path']);
|
||||
@@ -1238,7 +1289,7 @@ while ($row_a = $loop->fetch()) {
|
||||
$m['m']['SkimTrackCount'] = @count($m_base);
|
||||
foreach (@$m_base as $track) {
|
||||
if (!@$m['m']['SkimDims'] && @$track['Width'] && @$track['Height']) {
|
||||
$m['m']['SkimDims'] = sanitize($track['Width'],"i").$display_delimiter.sanitize($track['Height'],"i");
|
||||
$m['m']['SkimDims'] = @sanitize($track['Width'],"i").$display_delimiter.@sanitize($track['Height'],"i");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1279,7 +1330,7 @@ while ($row_a = $loop->fetch()) {
|
||||
// find a single value
|
||||
list($kind,$item) = explode("^",$dindex);
|
||||
if (@$m[$kind][$item]) {
|
||||
$stmt->BindValue(":".$name,sanitize($m[$kind][$item],$type));
|
||||
$stmt->BindValue(":".$name,@sanitize($m[$kind][$item],$type));
|
||||
$found = 1;
|
||||
}
|
||||
|
||||
@@ -1322,7 +1373,8 @@ if ($p['postflight'] == 2 && $p['rsync_dest']) {
|
||||
}
|
||||
|
||||
$done = "Finished ".$zpath." in ".$seconds." seconds";
|
||||
echo msg($done); notification($done);
|
||||
$done_m = "Memory usage: ".prettysize(memory_get_usage(true));
|
||||
echo msg($done."\n".$done_m); notification($done);
|
||||
|
||||
unset($dbo, $dbp, $files, $family, $fx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user