summaryrefslogtreecommitdiffstats
path: root/lib/private/files/cache/storage.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-06-06 11:39:35 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-06 11:39:35 +0200
commit26993f216744e78a22adb62c5c7aa233027db98a (patch)
tree81d1df4c7d33b50053bd783d51f629c34967ee95 /lib/private/files/cache/storage.php
parent3a7b30795c56f1debdb7a9dcd51578b711c2f622 (diff)
downloadnextcloud-server-26993f216744e78a22adb62c5c7aa233027db98a.tar.gz
nextcloud-server-26993f216744e78a22adb62c5c7aa233027db98a.zip
No need to create a storage within remove
Diffstat (limited to 'lib/private/files/cache/storage.php')
-rw-r--r--lib/private/files/cache/storage.php32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/private/files/cache/storage.php b/lib/private/files/cache/storage.php
index 6b6b0bce9d7..3a267874431 100644
--- a/lib/private/files/cache/storage.php
+++ b/lib/private/files/cache/storage.php
@@ -43,12 +43,15 @@ class Storage {
}
}
+ /**
+ * @return string
+ */
public function getNumericId() {
return $this->numericId;
}
/**
- * @return string
+ * @return string|null
*/
public static function getStorageId($numericId) {
@@ -62,37 +65,46 @@ class Storage {
}
/**
- * @param string $storageId
+ * @return string|null
*/
- public static function exists($storageId) {
+ public static function getNumericStorageId($storageId) {
if (strlen($storageId) > 64) {
$storageId = md5($storageId);
}
+
$sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
$result = \OC_DB::executeAudited($sql, array($storageId));
if ($row = $result->fetchRow()) {
- return true;
+ return $row['numeric_id'];
} else {
- return false;
+ return null;
}
}
/**
+ * @param string $storageId
+ * @return bool
+ */
+ public static function exists($storageId) {
+ return !is_null(self::getNumericStorageId($storageId));
+ }
+
+ /**
* remove the entry for the storage
*
* @param string $storageId
*/
public static function remove($storageId) {
- $storageCache = new Storage($storageId);
- $numericId = $storageCache->getNumericId();
-
if (strlen($storageId) > 64) {
$storageId = md5($storageId);
}
$sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
\OC_DB::executeAudited($sql, array($storageId));
- $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?';
- \OC_DB::executeAudited($sql, array($numericId));
+ $numericId = self::exists($storageId);
+ if (!is_null($numericId)) {
+ $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?';
+ \OC_DB::executeAudited($sql, array($numericId));
+ }
}
}