This commit is contained in:
Shish 2020-02-04 01:14:11 +00:00
commit d13c91ff9a
5 changed files with 19 additions and 14 deletions

View File

@ -25,6 +25,7 @@ function log_msg(string $section, int $priority, string $message, ?string $flash
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && ($priority >= $threshold)) { if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && ($priority >= $threshold)) {
print date("c")." $section: $message\n"; print date("c")." $section: $message\n";
ob_flush();
} }
if (!is_null($flash)) { if (!is_null($flash)) {
$page->flash($flash); $page->flash($flash);

View File

@ -107,11 +107,11 @@ class BulkActions extends Extension
if (count($event->args) < 2) { if (count($event->args) < 2) {
return; return;
} }
$query = $event->args[0]; $action = $event->args[0];
$items = $this->yield_search_results($event->args[1]); $query = $event->args[1];
$newEvent = new BulkActionEvent($event->args[0], $items); $items = $this->yield_search_results($query);
var_dump($newEvent); log_info("bulk_actions", "Performing $action on {$event->args[1]}");
# send_event($newEvent); send_event(new BulkActionEvent($event->args[0], $items));
} }
} }

View File

@ -154,7 +154,7 @@ class Index extends Extension
} }
if ($event->cmd == "search") { if ($event->cmd == "search") {
$query = count($event->args) > 0 ? Tag::explode($event->args[0]) : []; $query = count($event->args) > 0 ? Tag::explode($event->args[0]) : [];
$items = Image::find_images(0, 100, $query); $items = Image::find_images(0, 1000, $query);
foreach ($items as $item) { foreach ($items as $item) {
print("{$item->hash}\n"); print("{$item->hash}\n");
} }

View File

@ -167,8 +167,9 @@ class Media extends Extension
$failed = 0; $failed = 0;
foreach ($event->items as $image) { foreach ($event->items as $image) {
try { try {
log_debug("media", "Rescanning media for {$image->hash} ({$image->id})");
send_event(new MediaCheckPropertiesEvent($image)); send_event(new MediaCheckPropertiesEvent($image));
$image->save_media_properties(); $image->save_to_db();
$total++; $total++;
} catch (MediaException $e) { } catch (MediaException $e) {
$failed++; $failed++;
@ -373,10 +374,10 @@ class Media extends Extension
exec($cmd, $output, $ret); exec($cmd, $output, $ret);
if ((int)$ret == (int)0) { if ((int)$ret == (int)0) {
log_debug('Media', "Generating thumbnail with command `$cmd`, returns $ret"); log_debug('media', "Generating thumbnail with command `$cmd`, returns $ret");
return true; return true;
} else { } else {
log_error('Media', "Generating thumbnail with command `$cmd`, returns $ret"); log_error('media', "Generating thumbnail with command `$cmd`, returns $ret");
return false; return false;
} }
} }
@ -405,11 +406,11 @@ class Media extends Extension
exec($cmd, $output, $ret); exec($cmd, $output, $ret);
if ((int)$ret == (int)0) { if ((int)$ret == (int)0) {
log_debug('Media', "Getting media data `$cmd`, returns $ret"); log_debug('media', "Getting media data `$cmd`, returns $ret");
$output = implode($output); $output = implode($output);
return json_decode($output, true); return json_decode($output, true);
} else { } else {
log_error('Media', "Getting media data `$cmd`, returns $ret"); log_error('media', "Getting media data `$cmd`, returns $ret");
return []; return [];
} }
} }
@ -617,7 +618,7 @@ class Media extends Extension
if ($ret != 0) { if ($ret != 0) {
throw new MediaException("Resizing image with command `$cmd`, returns $ret, outputting " . implode("\r\n", $output)); throw new MediaException("Resizing image with command `$cmd`, returns $ret, outputting " . implode("\r\n", $output));
} else { } else {
log_debug('Media', "Generating thumbnail with command `$cmd`, returns $ret"); log_debug('media', "Generating thumbnail with command `$cmd`, returns $ret");
} }
} }
@ -931,7 +932,7 @@ class Media extends Extension
} else { } else {
$size = [1, 1]; $size = [1, 1];
} }
log_debug('Media', "Getting video size with `$cmd`, returns $output -- $size[0], $size[1]"); log_debug('media', "Getting video size with `$cmd`, returns $output -- $size[0], $size[1]");
return $size; return $size;
} }

View File

@ -152,7 +152,10 @@ try {
$_tracer->end(); $_tracer->end();
if (TRACE_FILE) { if (TRACE_FILE) {
if ((microtime(true) - $_shm_load_start) > TRACE_THRESHOLD && $_SERVER["REQUEST_URI"] != "/upload") { if (
(microtime(true) - $_shm_load_start) > TRACE_THRESHOLD
&& ($_SERVER["REQUEST_URI"] ?? "") != "/upload"
) {
$_tracer->flush(TRACE_FILE); $_tracer->flush(TRACE_FILE);
} }
} }