mirror of
https://github.com/getgrav/grav.git
synced 2026-09-03 07:33:21 +02:00
Minor media improvements
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user