From: Mikael Nordfeldth Date: Mon, 12 May 2014 12:41:12 +0000 (+0200) Subject: Thumbnail cleaning script, for missing files and File entries X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bf8c26f8359f1c26bf22bb81d57f5fdbe38c0b5f;p=quix0rs-gnu-social.git Thumbnail cleaning script, for missing files and File entries Should be safe to run at any time, since thumbnails are regenerated on demand. --- 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";