From bf8c26f8359f1c26bf22bb81d57f5fdbe38c0b5f Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 12 May 2014 14:41:12 +0200 Subject: [PATCH] Thumbnail cleaning script, for missing files and File entries Should be safe to run at any time, since thumbnails are regenerated on demand. --- scripts/clean_thumbnails.php | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 scripts/clean_thumbnails.php diff --git a/scripts/clean_thumbnails.php b/scripts/clean_thumbnails.php new file mode 100755 index 0000000000..aef3f54aff --- /dev/null +++ b/scripts/clean_thumbnails.php @@ -0,0 +1,66 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'y'; +$longoptions = array('yes'); + +$helptext = <<find(); +while ($thumbs->fetch()) { + try { + $file = $thumbs->getFile(); + if ($file->isLocal()) { + // only delete properly linked thumbnails if they're local + $thumbs->delete(); + print '.'; + } + } catch (NoResultException $e) { + // No File object for thumbnail, let's delete the thumbnail entry + $thumbs->delete(); + print 'x'; + } +} +print "\nDONE.\n";