diff --git a/scripts/generate-thumbs.php b/scripts/generate-thumbs.php index 96dae4cb..eda8e318 100644 --- a/scripts/generate-thumbs.php +++ b/scripts/generate-thumbs.php @@ -3,9 +3,13 @@ require_once __DIR__ . '/../src/core.php'; 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); $entityCount = PostSearchService::getEntityCount($query, null, null); $i = 0; @@ -13,6 +17,8 @@ foreach ($posts as $post) { ++ $i; printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount); + if ($post->tryGetWorkingThumbnailPath() and $force) + unlink($post->tryGetWorkingThumbnailPath()); if (!$post->tryGetWorkingThumbnailPath()) $post->generateThumbnail(); }