diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-02-15 21:49:40 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-02-15 22:11:39 +0100 |
commit | 0c1ec758e89517acac8971f87e3c5796124e40ca (patch) | |
tree | a953116699a6bd23735bb84e8f6d7dfe271d253a /lib/files/cache/cache.php | |
parent | 425d41aaf93e1cd3a44ddc794414683e8e2c4648 (diff) | |
download | nextcloud-server-0c1ec758e89517acac8971f87e3c5796124e40ca.tar.gz nextcloud-server-0c1ec758e89517acac8971f87e3c5796124e40ca.zip |
Cache: hash long storage ids to ensure they fit in the database
Diffstat (limited to 'lib/files/cache/cache.php')
-rw-r--r-- | lib/files/cache/cache.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 5feed37ae48..3652dc7cf23 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -48,6 +48,9 @@ class Cache { } else { $this->storageId = $storage; } + if (strlen($this->storageId) > 64) { + $this->storageId = md5($this->storageId); + } $query = \OC_DB::prepare('SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?'); $result = $query->execute(array($this->storageId)); @@ -199,7 +202,7 @@ class Cache { $valuesPlaceholder = array_fill(0, count($queryParts), '?'); $query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ')' - .' VALUES(' . implode(', ', $valuesPlaceholder) . ')'); + . ' VALUES(' . implode(', ', $valuesPlaceholder) . ')'); $query->execute($params); return (int)\OC_DB::insertid('*PREFIX*filecache'); @@ -217,7 +220,7 @@ class Cache { $params[] = $id; $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=?' - .' WHERE fileid = ?'); + . ' WHERE fileid = ?'); $query->execute($params); } @@ -335,7 +338,7 @@ class Cache { } $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =?' - .' WHERE `fileid` = ?'); + . ' WHERE `fileid` = ?'); $query->execute(array($target, md5($target), $newParentId, $sourceId)); } @@ -496,7 +499,7 @@ class Cache { */ public function getIncomplete() { $query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache`' - .' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1'); + . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1'); $query->execute(array($this->numericId)); if ($row = $query->fetchRow()) { return $row['path']; |