dont create empty filecache extended rows
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
2165f10aaf
commit
43fa746ad9
|
@ -292,6 +292,7 @@ class Cache implements ICache {
|
||||||
if ($builder->execute()) {
|
if ($builder->execute()) {
|
||||||
$fileId = $builder->getLastInsertId();
|
$fileId = $builder->getLastInsertId();
|
||||||
|
|
||||||
|
if (count($extensionValues)) {
|
||||||
$query = $this->getQueryBuilder();
|
$query = $this->getQueryBuilder();
|
||||||
$query->insert('filecache_extended');
|
$query->insert('filecache_extended');
|
||||||
|
|
||||||
|
@ -300,6 +301,7 @@ class Cache implements ICache {
|
||||||
$query->setValue($column, $query->createNamedParameter($value));
|
$query->setValue($column, $query->createNamedParameter($value));
|
||||||
}
|
}
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
}
|
||||||
|
|
||||||
$this->eventDispatcher->dispatch(CacheInsertEvent::class, new CacheInsertEvent($this->storage, $file, $fileId));
|
$this->eventDispatcher->dispatch(CacheInsertEvent::class, new CacheInsertEvent($this->storage, $file, $fileId));
|
||||||
return $fileId;
|
return $fileId;
|
||||||
|
@ -357,6 +359,17 @@ class Cache implements ICache {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($extensionValues)) {
|
if (count($extensionValues)) {
|
||||||
|
try {
|
||||||
|
$query = $this->getQueryBuilder();
|
||||||
|
$query->insert('filecache_extended');
|
||||||
|
|
||||||
|
$query->setValue('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT));
|
||||||
|
foreach ($extensionValues as $column => $value) {
|
||||||
|
$query->setValue($column, $query->createNamedParameter($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
} catch (UniqueConstraintViolationException $e) {
|
||||||
$query = $this->getQueryBuilder();
|
$query = $this->getQueryBuilder();
|
||||||
$query->update('filecache_extended')
|
$query->update('filecache_extended')
|
||||||
->whereFileId($id)
|
->whereFileId($id)
|
||||||
|
@ -373,6 +386,7 @@ class Cache implements ICache {
|
||||||
|
|
||||||
$query->execute();
|
$query->execute();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$path = $this->getPathById($id);
|
$path = $this->getPathById($id);
|
||||||
// path can still be null if the file doesn't exist
|
// path can still be null if the file doesn't exist
|
||||||
|
|
|
@ -718,7 +718,7 @@ class CacheTest extends \Test\TestCase {
|
||||||
$data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'metadata_etag' => 'foo'];
|
$data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'metadata_etag' => 'foo'];
|
||||||
$this->cache->put("foo3", $data);
|
$this->cache->put("foo3", $data);
|
||||||
$data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'];
|
$data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'];
|
||||||
$this->cache->put("foo4", $data);
|
$id4 = $this->cache->put("foo4", $data);
|
||||||
|
|
||||||
$entry = $this->cache->get($id1);
|
$entry = $this->cache->get($id1);
|
||||||
$this->assertEquals(20, $entry->getCreationTime());
|
$this->assertEquals(20, $entry->getCreationTime());
|
||||||
|
@ -766,6 +766,13 @@ class CacheTest extends \Test\TestCase {
|
||||||
$this->assertEquals(20, $entries[0]->getCreationTime());
|
$this->assertEquals(20, $entries[0]->getCreationTime());
|
||||||
$this->assertEquals(25, $entries[0]->getUploadTime());
|
$this->assertEquals(25, $entries[0]->getUploadTime());
|
||||||
$this->assertEquals(null, $entries[0]->getMetadataEtag());
|
$this->assertEquals(null, $entries[0]->getMetadataEtag());
|
||||||
|
|
||||||
|
$this->cache->update($id4, ['upload_time' => 25]);
|
||||||
|
|
||||||
|
$entry = $this->cache->get($id4);
|
||||||
|
$this->assertEquals(0, $entry->getCreationTime());
|
||||||
|
$this->assertEquals(25, $entry->getUploadTime());
|
||||||
|
$this->assertEquals(null, $entry->getMetadataEtag());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown() {
|
protected function tearDown() {
|
||||||
|
|
Loading…
Reference in New Issue