diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-03-25 12:52:32 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-08-20 23:14:05 +0200 |
commit | 068f9d10f1fec99cebf2ec29de2a09b4b34362b5 (patch) | |
tree | f1d2bc74607daa8405d4ced6f038d044022ca514 /lib/private/files | |
parent | 36c88e28307da569fea7a86d18ad559aa0b3f868 (diff) | |
download | nextcloud-server-068f9d10f1fec99cebf2ec29de2a09b4b34362b5.tar.gz nextcloud-server-068f9d10f1fec99cebf2ec29de2a09b4b34362b5.zip |
Added repair step for legacy storages
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/cache/storage.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/private/files/cache/storage.php b/lib/private/files/cache/storage.php index 9ad31a272ea..a38656d8499 100644 --- a/lib/private/files/cache/storage.php +++ b/lib/private/files/cache/storage.php @@ -28,9 +28,7 @@ class Storage { } else { $this->storageId = $storage; } - if (strlen($this->storageId) > 64) { - $this->storageId = md5($this->storageId); - } + $this->storageId = self::adjustStorageId($this->storageId); $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?'; $result = \OC_DB::executeAudited($sql, array($this->storageId)); @@ -44,6 +42,19 @@ class Storage { } /** + * Adjusts the storage id to use md5 if too long + * @param string $storageId storage id + * @return unchanged $storageId if its length is less than 64 characters, + * else returns the md5 of $storageId + */ + public static function adjustStorageId($storageId) { + if (strlen($storageId) > 64) { + return md5($storageId); + } + return $storageId; + } + + /** * @return string */ public function getNumericId() { @@ -68,9 +79,7 @@ class Storage { * @return string|null */ public static function getNumericStorageId($storageId) { - if (strlen($storageId) > 64) { - $storageId = md5($storageId); - } + $storageId = self::adjustStorageId($storageId); $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?'; $result = \OC_DB::executeAudited($sql, array($storageId)); @@ -95,9 +104,7 @@ class Storage { * @param string $storageId */ public static function remove($storageId) { - if (strlen($storageId) > 64) { - $storageId = md5($storageId); - } + $storageId = self::adjustStorageId($storageId); $sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?'; \OC_DB::executeAudited($sql, array($storageId)); |