summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2013-02-18 07:17:27 -0800
committerFrank Karlitschek <frank@owncloud.org>2013-02-18 07:17:27 -0800
commitf554347db5271e3ae7e251369e5d73e7ab6cec93 (patch)
tree62ba9c098bce6b8abc7d4e410a649ace1a7d844e /lib
parent0ab87204ec7568f26fc2f930e1004b3293b45676 (diff)
parent0c1ec758e89517acac8971f87e3c5796124e40ca (diff)
downloadnextcloud-server-f554347db5271e3ae7e251369e5d73e7ab6cec93.tar.gz
nextcloud-server-f554347db5271e3ae7e251369e5d73e7ab6cec93.zip
Merge pull request #1724 from owncloud/long-storage-id
Cache: hash long storage ids to ensure they fit in the database
Diffstat (limited to 'lib')
-rw-r--r--lib/files/cache/cache.php11
-rw-r--r--lib/files/mount.php6
2 files changed, 13 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'];
diff --git a/lib/files/mount.php b/lib/files/mount.php
index 74ee483b1be..6e99d8eabb4 100644
--- a/lib/files/mount.php
+++ b/lib/files/mount.php
@@ -93,6 +93,9 @@ class Mount {
$this->storage = $this->createStorage();
}
$this->storageId = $this->storage->getId();
+ if (strlen($this->storageId) > 64) {
+ $this->storageId = md5($this->storageId);
+ }
}
return $this->storageId;
}
@@ -177,6 +180,9 @@ class Mount {
* @return \OC\Files\Storage\Storage[]
*/
public static function findById($id) {
+ if (strlen($id) > 64) {
+ $id = md5($id);
+ }
$result = array();
foreach (self::$mounts as $mount) {
if ($mount->getStorageId() === $id) {