Files
projectsend/app/Modules/Files/Thumbnails/RenderedImageCache.php
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

40 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Files\Thumbnails;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Throwable;
/**
* Every cached rendition on the local 'files' disk, as one addressable
* thing — so that "forget everything we rendered under the old rules"
* has a single definition instead of a `deleteDirectory()` per rendition
* scattered wherever a rendering setting can change.
*
* Always the local disk regardless of where the originals live: a
* rendition is a derived artifact, never pushed to external storage.
* See FileThumbnailController.
*/
class RenderedImageCache
{
public function flush(): void
{
foreach (ImageRendition::cases() as $rendition) {
try {
Storage::disk('files')->deleteDirectory($rendition->directory());
} catch (Throwable $exception) {
// Everything rebuilds itself lazily on the next request, so
// a storage hiccup here means "some stale images survive",
// not "the settings change failed" — and the person who just
// saved a setting should not get a 500 for it. Per rendition
// rather than around the loop, so one failing directory does
// not leave the others unflushed.
Log::warning("Could not flush the {$rendition->value} cache: ".$exception->getMessage());
}
}
}
}