Added --force for thumbnail generator script
This commit is contained in:
parent
0acfd17165
commit
956283f4a0
1 changed files with 8 additions and 2 deletions
|
@ -3,9 +3,13 @@ require_once __DIR__ . '/../src/core.php';
|
||||||
|
|
||||||
Access::disablePrivilegeChecking();
|
Access::disablePrivilegeChecking();
|
||||||
|
|
||||||
array_shift($argv);
|
$options = getopt('f', ['force']);
|
||||||
|
$force = (isset($options['f']) or isset($options['force']));
|
||||||
|
|
||||||
$query = array_shift($argv);
|
$args = array_search('--', $argv);
|
||||||
|
$args = array_splice($argv, $args ? ++$args : (count($argv) - count($options)));
|
||||||
|
|
||||||
|
$query = array_shift($args);
|
||||||
$posts = PostSearchService::getEntities($query, null, null);
|
$posts = PostSearchService::getEntities($query, null, null);
|
||||||
$entityCount = PostSearchService::getEntityCount($query, null, null);
|
$entityCount = PostSearchService::getEntityCount($query, null, null);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -13,6 +17,8 @@ foreach ($posts as $post)
|
||||||
{
|
{
|
||||||
++ $i;
|
++ $i;
|
||||||
printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount);
|
printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount);
|
||||||
|
if ($post->tryGetWorkingThumbnailPath() and $force)
|
||||||
|
unlink($post->tryGetWorkingThumbnailPath());
|
||||||
if (!$post->tryGetWorkingThumbnailPath())
|
if (!$post->tryGetWorkingThumbnailPath())
|
||||||
$post->generateThumbnail();
|
$post->generateThumbnail();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue