Minor media improvements

This commit is contained in:
Matias Griese
2022-02-04 19:21:28 +02:00
parent 815423ce44
commit c93b9414fe
3 changed files with 5 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ class Media extends LocalMedia
public function __construct(?string $path, array $media_order = null, bool $load = true)
{
$this->setPath($path);
$this->indexTimeout = 60;
$this->media_order = $media_order;
if ($load) {

View File

@@ -474,7 +474,8 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac
// Get file media listing. Use cached version if possible to avoid I/O.
$now = time();
[$files, $timestamp] = $this->loadIndex();
if ($timestamp < $now - $this->indexTimeout) {
$timeout = $this->indexTimeout;
if (!$timestamp || ($timeout && $timestamp < $now - $timeout)) {
$media_types = $config->get('media.types');
$files = $this->prepareFileInfo($this->loadFileInfo(), $media_types, $files);

View File

@@ -189,8 +189,9 @@ abstract class LocalMedia extends AbstractMedia
$index = $indexFile && $indexFile->exists() ? $indexFile->load() : [];
$version = $index['version'] ?? null;
$type = $index['type'] ?? null;
$folder = $index['folder'] ?? null;
if ($version !== static::VERSION || $folder !== $this->path) {
if ($version !== static::VERSION || $folder !== $this->path || $type !== ($this->config['type'] ?? 'local')) {
$index = [];
}