summaryrefslogtreecommitdiffstats
path: root/lib/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-01-30 18:17:56 +0100
committerRobin Appelman <icewind@owncloud.com>2013-01-30 19:19:19 +0100
commitaf3b0e30ed2dd66212c3fc25bb5c406b77fa9e5d (patch)
tree070ab6bf21e5fbc20eaff2a42d59392e7b52fc94 /lib/files
parentca4c006d5ab71acbd15ea011fba72eaddc34a901 (diff)
downloadnextcloud-server-af3b0e30ed2dd66212c3fc25bb5c406b77fa9e5d.tar.gz
nextcloud-server-af3b0e30ed2dd66212c3fc25bb5c406b77fa9e5d.zip
Cache: don't insert duplicated during upgrade
Diffstat (limited to 'lib/files')
-rw-r--r--lib/files/cache/upgrade.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php
index 19e3d9ad575..eb8c7297c3e 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/files/cache/upgrade.php
@@ -64,12 +64,25 @@ class Upgrade {
* @param array $data the data for the new cache
*/
function insert($data) {
- $insertQuery = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`
- ( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` )
- VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
+ if (!$this->inCache($data['storage'], $data['path_hash'])) {
+ $insertQuery = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`
+ ( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` )
+ VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
- $insertQuery->execute(array($data['id'], $data['storage'], $data['path'], $data['path_hash'], $data['parent'], $data['name'],
- $data['mimetype'], $data['mimepart'], $data['size'], $data['mtime'], $data['encrypted']));
+ $insertQuery->execute(array($data['id'], $data['storage'], $data['path'], $data['path_hash'], $data['parent'], $data['name'],
+ $data['mimetype'], $data['mimepart'], $data['size'], $data['mtime'], $data['encrypted']));
+ }
+ }
+
+ /**
+ * @param string $storage
+ * @param string $pathHash
+ * @return bool
+ */
+ function inCache($storage, $pathHash) {
+ $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
+ $result = $query->execute(array($storage, $pathHash));
+ return (bool)$result->fetchRow();
}
/**