summaryrefslogtreecommitdiffstats
path: root/lib/files/cache/upgrade.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-12-15 23:28:07 +0100
committerRobin Appelman <icewind@owncloud.com>2012-12-15 23:35:07 +0100
commitb12abb2c94072ab5b84d0477ecb7ce9789bdda0d (patch)
treecdd4f210908ad9fb4aa1ec488bfd5eb70f2506db /lib/files/cache/upgrade.php
parent8951769cae5f1acc9b709ac676fffe26513d14f6 (diff)
downloadnextcloud-server-b12abb2c94072ab5b84d0477ecb7ce9789bdda0d.tar.gz
nextcloud-server-b12abb2c94072ab5b84d0477ecb7ce9789bdda0d.zip
use numeric ids for storages in the filecache
Diffstat (limited to 'lib/files/cache/upgrade.php')
-rw-r--r--lib/files/cache/upgrade.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php
index 9219deebef5..77db4c2339e 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/files/cache/upgrade.php
@@ -11,6 +11,8 @@ namespace OC\Files\Cache;
class Upgrade {
static $permissionsCaches = array();
+ static $numericIds = array();
+
static function upgrade() {
$insertQuery = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` )
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
@@ -32,7 +34,7 @@ class Upgrade {
$checkExistingQuery = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
while ($row = $oldEntriesResult->fetchRow()) {
- if($checkExistingQuery->execute(array($row['id']))->fetchRow()){
+ if ($checkExistingQuery->execute(array($row['id']))->fetchRow()) {
continue;
}
@@ -42,7 +44,7 @@ class Upgrade {
* @var string $internalPath;
*/
$pathHash = md5($internalPath);
- $storageId = $storage->getId();
+ $storageId = self::getNumericId($storage);
$parentId = ($internalPath === '') ? -1 : $row['parent'];
$insertQuery->execute(array($row['id'], $storageId, $internalPath, $pathHash, $parentId, $row['name'], $row['mimetype'], $row['mimepart'], $row['size'], $row['mtime'], $row['encrypted']));
@@ -64,4 +66,19 @@ class Upgrade {
}
return self::$permissionsCaches[$storageId];
}
+
+ /**
+ * get the numeric storage id
+ *
+ * @param \OC\Files\Storage\Storage $storage
+ * @return int
+ */
+ static function getNumericId($storage) {
+ $storageId = $storage->getId();
+ if (!isset(self::$numericIds[$storageId])) {
+ $cache = new Cache($storage);
+ self::$numericIds[$storageId] = $cache->getNumericStorageId();
+ }
+ return self::$numericIds[$storageId];
+ }
}