Cache: also check if the file id is already in the cache during upgrade

Should solve upgrade issues if only some of the configured storages were migrated previously
This commit is contained in:
Robin Appelman 2013-03-04 22:26:03 +01:00
parent 416607e559
commit 56ae4bb6e9
1 changed files with 10 additions and 3 deletions

View File

@ -64,7 +64,7 @@ class Upgrade {
* @param array $data the data for the new cache
*/
function insert($data) {
if (!$this->inCache($data['storage'], $data['path_hash'])) {
if (!$this->inCache($data['storage'], $data['path_hash'], $data['id'])) {
$insertQuery = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`
( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` )
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
@ -78,13 +78,20 @@ class Upgrade {
/**
* @param string $storage
* @param string $pathHash
* @param string $id
* @return bool
*/
function inCache($storage, $pathHash) {
function inCache($storage, $pathHash, $id) {
$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
$result = $query->execute(array($storage, $pathHash));
if ($result->fetchRow()) {
return true;
} else {
$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
$result = $query->execute(array($id));
return (bool)$result->fetchRow();
}
}
/**
* get the new data array from the old one