diff options
author | Robin Appelman <robin@icewind.nl> | 2018-12-10 17:20:45 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-12-12 14:17:19 +0100 |
commit | 6c9f2644cf8bac151b9af743802eb72a51278e8b (patch) | |
tree | 161b589821f998cc1e9bc7e7834730fadb5f5edb /lib/private | |
parent | 71df6233cfc4c6a02f90a887d57471430fe38dd7 (diff) | |
download | nextcloud-server-6c9f2644cf8bac151b9af743802eb72a51278e8b.tar.gz nextcloud-server-6c9f2644cf8bac151b9af743802eb72a51278e8b.zip |
Add objectExists to objectstore interface
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/ObjectStore/Azure.php | 13 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/S3ObjectTrait.php | 4 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/StorageObjectStore.php | 3 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/Swift.php | 3 |
4 files changed, 23 insertions, 0 deletions
diff --git a/lib/private/Files/ObjectStore/Azure.php b/lib/private/Files/ObjectStore/Azure.php index 899c826ec19..e162c510b98 100644 --- a/lib/private/Files/ObjectStore/Azure.php +++ b/lib/private/Files/ObjectStore/Azure.php @@ -115,4 +115,17 @@ class Azure implements IObjectStore { public function deleteObject($urn) { $this->getBlobClient()->deleteBlob($this->containerName, $urn); } + + public function objectExists($urn) { + try { + $this->getBlobClient()->getBlobMetadata($this->containerName, $urn); + return true; + } catch (ServiceException $e) { + if ($e->getCode() === 404) { + return false; + } else { + throw $e; + } + } + } } diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index 280a8efa81c..a1110d87c8f 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -90,4 +90,8 @@ trait S3ObjectTrait { 'Key' => $urn ]); } + + public function objectExists($urn) { + return $this->getConnection()->doesObjectExist($this->bucket, $urn); + } } diff --git a/lib/private/Files/ObjectStore/StorageObjectStore.php b/lib/private/Files/ObjectStore/StorageObjectStore.php index 0d35ba2ed7a..f9fc1b5a4aa 100644 --- a/lib/private/Files/ObjectStore/StorageObjectStore.php +++ b/lib/private/Files/ObjectStore/StorageObjectStore.php @@ -89,4 +89,7 @@ class StorageObjectStore implements IObjectStore { $this->storage->unlink($urn); } + public function objectExists($urn) { + return $this->storage->file_exists($urn); + } } diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index e379e54d018..3d6bf9d69da 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -128,4 +128,7 @@ class Swift implements IObjectStore { $this->getContainer()->delete(); } + public function objectExists($urn) { + return $this->getContainer()->objectExists($urn); + } } |