mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #55907 from nextcloud/carl/fix-preview-object-store
fix(preview): Fix deleting dummy preview in object store
This commit is contained in:
commit
492a8c3a8b
2 changed files with 12 additions and 5 deletions
|
|
@ -25,8 +25,8 @@ use OCP\Files\IMimeTypeDetector;
|
|||
* @method void setOldFileId(int $oldFileId)
|
||||
* @method int getLocationId() Get the location id in the preview_locations table. Only set when using an object store as primary storage.
|
||||
* @method void setLocationId(int $locationId)
|
||||
* @method string getBucketName() Get the bucket name where the preview is stored. This is stored in the preview_locations table.
|
||||
* @method string getObjectStoreName() Get the object store name where the preview is stored. This is stored in the preview_locations table.
|
||||
* @method string|null getBucketName() Get the bucket name where the preview is stored. This is stored in the preview_locations table.
|
||||
* @method string|null getObjectStoreName() Get the object store name where the preview is stored. This is stored in the preview_locations table.
|
||||
* @method int getWidth() Get the width of the preview.
|
||||
* @method void setWidth(int $width)
|
||||
* @method int getHeight() Get the height of the preview.
|
||||
|
|
|
|||
|
|
@ -77,6 +77,11 @@ class ObjectStorePreviewStorage implements IPreviewStorage {
|
|||
|
||||
#[Override]
|
||||
public function deletePreview(Preview $preview): void {
|
||||
if (defined('PHPUNIT_RUN') && $preview->getLocationId() === null) {
|
||||
// Should only be the case in unit tests when adding dummy previews in the database.
|
||||
return;
|
||||
}
|
||||
|
||||
[
|
||||
'urn' => $urn,
|
||||
'store' => $store,
|
||||
|
|
@ -100,10 +105,12 @@ class ObjectStorePreviewStorage implements IPreviewStorage {
|
|||
* @return ObjectStoreDefinition
|
||||
*/
|
||||
private function getObjectStoreInfoForExistingPreview(Preview $preview): array {
|
||||
assert(!empty($preview->getObjectStoreName()));
|
||||
assert(!empty($preview->getBucketName()));
|
||||
$objectStoreName = $preview->getObjectStoreName();
|
||||
$bucketName = $preview->getBucketName();
|
||||
assert(!empty($objectStoreName));
|
||||
assert(!empty($bucketName));
|
||||
|
||||
$config = $this->objectStoreConfig->getObjectStoreConfiguration($preview->getObjectStoreName());
|
||||
$config = $this->objectStoreConfig->getObjectStoreConfiguration($objectStoreName);
|
||||
$config['arguments']['bucket'] = $preview->getBucketName();
|
||||
$objectStoreName = $preview->getObjectStoreName();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue