Skip to content

Commit e6648f3

Browse files
authored
Merge pull request #49434 from nextcloud/artonge/fix/getting_cache_entry
fix: Wrap partial cache entry in CacheEntry
2 parents 1681283 + f9cda54 commit e6648f3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/private/Files/Cache/Cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ public function insert($file, array $data) {
249249
$file = $this->normalize($file);
250250

251251
if (isset($this->partial[$file])) { //add any saved partial data
252-
$data = array_merge($this->partial[$file], $data);
252+
$data = array_merge($this->partial[$file]->getData(), $data);
253253
unset($this->partial[$file]);
254254
}
255255

256256
$requiredFields = ['size', 'mtime', 'mimetype'];
257257
foreach ($requiredFields as $field) {
258258
if (!isset($data[$field])) { //data not complete save as partial and return
259-
$this->partial[$file] = $data;
259+
$this->partial[$file] = new CacheEntry($data);
260260
return -1;
261261
}
262262
}

tests/lib/Files/Cache/CacheTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Test\Files\Cache;
99

1010
use OC\Files\Cache\Cache;
11+
use OC\Files\Cache\CacheEntry;
1112
use OC\Files\Search\SearchComparison;
1213
use OC\Files\Search\SearchQuery;
1314
use OCP\EventDispatcher\IEventDispatcher;
@@ -127,13 +128,13 @@ public function testPartial(): void {
127128
$file1 = 'foo';
128129

129130
$this->cache->put($file1, ['size' => 10]);
130-
$this->assertEquals(['size' => 10], $this->cache->get($file1));
131+
$this->assertEquals(new CacheEntry(['size' => 10]), $this->cache->get($file1));
131132

132133
$this->cache->put($file1, ['mtime' => 15]);
133-
$this->assertEquals(['size' => 10, 'mtime' => 15], $this->cache->get($file1));
134+
$this->assertEquals(new CacheEntry(['size' => 10, 'mtime' => 15]), $this->cache->get($file1));
134135

135136
$this->cache->put($file1, ['size' => 12]);
136-
$this->assertEquals(['size' => 12, 'mtime' => 15], $this->cache->get($file1));
137+
$this->assertEquals(new CacheEntry(['size' => 12, 'mtime' => 15]), $this->cache->get($file1));
137138
}
138139

139140
/**

0 commit comments

Comments
 (0)