Skip to content

Commit

Permalink
work around error - where "$numericId = $cache->getNumericStorageId()…
Browse files Browse the repository at this point in the history
…;" was returning null
  • Loading branch information
NacreData committed May 3, 2016
1 parent e777b87 commit 65615c6
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions db/statusmapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,46 +140,28 @@ public function update(Entity $entity){
* @return array
*/
public function getUnindexed() {
$files = array();
//TODO use server api for mounts & root
$absoluteRoot = Filesystem::getView()->getAbsolutePath('/');
$mounts = Filesystem::getMountPoints($absoluteRoot);
$mount = Filesystem::getMountPoint($absoluteRoot);
if (!in_array($mount, $mounts)) {
$mounts[] = $mount;
$user = \OC::$server->getUserSession()->getUser();
if (!$user) {
return false;
}
$full_home_dir = $user->getHome() . '/';

$files = array();

$query = $this->db->prepareQuery('
SELECT `*PREFIX*filecache`.`fileid`
SELECT `*PREFIX*filecache`.`fileid`, `*PREFIX*filecache`.`path`
FROM `*PREFIX*filecache`
LEFT JOIN `' . $this->tableName . '`
ON `*PREFIX*filecache`.`fileid` = `' . $this->tableName . '`.`fileid`
WHERE `storage` = ?
AND ( `status` IS NULL OR `status` = ? )
WHERE ( `status` IS NULL OR `status` = ? )
AND `path` LIKE \'files/%\'
');
$result = $query->execute([Status::STATUS_NEW]);
while ($row = $result->fetchRow()) {
if (file_exists($full_home_dir . $row['path'])
&& is_file($full_home_dir . $row['path'])) {

foreach ($mounts as $mount) {
if (is_string($mount)) {
$storage = Filesystem::getStorage($mount);
} else if ($mount instanceof Mount) {
$storage = $mount->getStorage();
} else {
$storage = null;
$this->logger->
debug( 'expected string or instance of \OC\Files\Mount\Mount got ' . json_encode($mount) );
}

//only index local files for now
if ($storage && $storage->isLocal()) {
$cache = $storage->getCache();
$numericId = $cache->getNumericStorageId();

$result = $query->execute(array($numericId, Status::STATUS_NEW));

while ($row = $result->fetchRow()) {
$files[] = $row['fileid'];
}
$files[] = $row['fileid'];
}
}
return $files;
Expand Down

0 comments on commit 65615c6

Please sign in to comment.