fix: Wrap partial cache entry in CacheEntry

Because it is returned here: 7b7d07c575/lib/private/Files/Cache/Cache.php (L136-L137)

And some implementation got stricter: df95bf6ba8/lib/Mount/RootEntryCache.php (L23-L28)

Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
Louis Chemineau 2024-11-21 17:13:24 +01:00
parent 1681283715
commit f9cda54cbf
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View file

@ -249,14 +249,14 @@ class Cache implements ICache {
$file = $this->normalize($file);
if (isset($this->partial[$file])) { //add any saved partial data
$data = array_merge($this->partial[$file], $data);
$data = array_merge($this->partial[$file]->getData(), $data);
unset($this->partial[$file]);
}
$requiredFields = ['size', 'mtime', 'mimetype'];
foreach ($requiredFields as $field) {
if (!isset($data[$field])) { //data not complete save as partial and return
$this->partial[$file] = $data;
$this->partial[$file] = new CacheEntry($data);
return -1;
}
}

View file

@ -8,6 +8,7 @@
namespace Test\Files\Cache;
use OC\Files\Cache\Cache;
use OC\Files\Cache\CacheEntry;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OCP\EventDispatcher\IEventDispatcher;
@ -127,13 +128,13 @@ class CacheTest extends \Test\TestCase {
$file1 = 'foo';
$this->cache->put($file1, ['size' => 10]);
$this->assertEquals(['size' => 10], $this->cache->get($file1));
$this->assertEquals(new CacheEntry(['size' => 10]), $this->cache->get($file1));
$this->cache->put($file1, ['mtime' => 15]);
$this->assertEquals(['size' => 10, 'mtime' => 15], $this->cache->get($file1));
$this->assertEquals(new CacheEntry(['size' => 10, 'mtime' => 15]), $this->cache->get($file1));
$this->cache->put($file1, ['size' => 12]);
$this->assertEquals(['size' => 12, 'mtime' => 15], $this->cache->get($file1));
$this->assertEquals(new CacheEntry(['size' => 12, 'mtime' => 15]), $this->cache->get($file1));
}
/**