From 6c8e826028b62f46244513558486ba488c183aa8 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sun, 21 Feb 2021 09:03:12 +0000 Subject: [PATCH] [MEDIA][SCRIPTS] clean_thumbnails Allow to delete remote thumbs as well If the sysadmin decides that StoreRemoteMedia plugin should store original, then its thumbs will be regenerated as well, making it safe to delete them if needed. Beware that Embed plugin never stores the original tho. --- scripts/clean_thumbnails.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 '.'; }