Clean attachments command now works on secure attachments too.

This commit is contained in:
Jan Böhmer 2019-10-19 19:36:33 +02:00
parent 63dc22f524
commit d859d8533d

View file

@ -50,10 +50,15 @@ class CleanAttachmentsCommand extends Command
$mediaPath = $this->pathResolver->getMediaPath(); $mediaPath = $this->pathResolver->getMediaPath();
$io->note("The media path is " . $mediaPath); $io->note("The media path is " . $mediaPath);
$securePath = $this->pathResolver->getSecurePath();
$io->note("The secure media path is ". $securePath);
$finder = new Finder(); $finder = new Finder();
//We look for files in the media folder only //We look for files in the media folder only
$finder->files()->in($mediaPath); $finder->files()->in([$mediaPath, $securePath]);
//Ignore image cache folder
$finder->exclude('cache');
$fs = new Filesystem(); $fs = new Filesystem();
$file_list = array(); $file_list = array();
@ -62,8 +67,7 @@ class CleanAttachmentsCommand extends Command
$table->setHeaders(['Filename', 'MIME Type', 'Last modified date']); $table->setHeaders(['Filename', 'MIME Type', 'Last modified date']);
$dateformatter = \IntlDateFormatter::create(null, \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT); $dateformatter = \IntlDateFormatter::create(null, \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
foreach ($finder as $file) foreach ($finder as $file) {
{
//If not attachment object uses this file, print it //If not attachment object uses this file, print it
if (count($this->reverseSearch->findAttachmentsByFile($file)) == 0) { if (count($this->reverseSearch->findAttachmentsByFile($file)) == 0) {
$file_list[] = $file; $file_list[] = $file;