diff --git a/scripts/clean_thumbnails.php b/scripts/clean_thumbnails.php index dd3e9a0875..5a3dbf82d4 100755 --- a/scripts/clean_thumbnails.php +++ b/scripts/clean_thumbnails.php @@ -21,8 +21,8 @@ define('INSTALLDIR', dirname(__DIR__)); define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); -$shortoptions = 'y'; -$longoptions = array('yes'); +$shortoptions = 'y::a::f'; +$longoptions = ['yes', 'all', 'force']; $helptext = <<find(); while ($thumbs->fetch()) { try { $file = $thumbs->getFile(); - if ($file->isLocal()) { - // only delete properly linked thumbnails if they're local + $is_local = $file->isLocal(); + if ($is_local || !$only_local) { + // only delete if we can regenerate it + if (!$is_local && !have_option('f', 'force')) { + try { + $file->getPath(); + } catch (Exception $e) { + // We can't regenerate later if we don't have the original. + continue; + } + } $thumbs->delete(); print '.'; }