aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis <louis@chmn.me>2024-11-21 19:53:38 +0100
committerGitHub <noreply@github.com>2024-11-21 19:53:38 +0100
commite6648f3dd10a897674441dfead8920bbe3b718c0 (patch)
treef59c974c784322a7d24675c38f9758b62a7d7961
parent16812837157395c078a9689cd51530a6382e17d2 (diff)
parentf9cda54cbf5559372b0e9e22dac41483c18a6988 (diff)
downloadnextcloud-server-e6648f3dd10a897674441dfead8920bbe3b718c0.tar.gz
nextcloud-server-e6648f3dd10a897674441dfead8920bbe3b718c0.zip
Merge pull request #49434 from nextcloud/artonge/fix/getting_cache_entry
fix: Wrap partial cache entry in CacheEntry
-rw-r--r--lib/private/Files/Cache/Cache.php4
-rw-r--r--tests/lib/Files/Cache/CacheTest.php7
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 59d5a838d72..da798af46cd 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -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;
}
}
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index d1279af29ad..204f87d6a18 100644
--- a/tests/lib/Files/Cache/CacheTest.php
+++ b/tests/lib/Files/Cache/CacheTest.php
@@ -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));
}
/**