add Cache->getIncomplete for use in background scanning
This commit is contained in:
parent
e6cf082fe0
commit
186c9e77e8
|
@ -402,4 +402,23 @@ class Cache {
|
||||||
}
|
}
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find a folder in the cache which has not been fully scanned
|
||||||
|
*
|
||||||
|
* If multiply incomplete folders are in the cache, the one with the highest id will be returned,
|
||||||
|
* use the one with the highest id gives the best result with the background scanner, since that is most
|
||||||
|
* likely the folder where we stopped scanning previously
|
||||||
|
*
|
||||||
|
* @return string|bool the path of the folder or false when no folder matched
|
||||||
|
*/
|
||||||
|
public function getIncomplete(){
|
||||||
|
$query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1');
|
||||||
|
$query->execute(array($this->storageId));
|
||||||
|
if($row = $query->fetchRow()){
|
||||||
|
return $row['path'];
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,23 @@ class Cache extends \UnitTestCase {
|
||||||
$this->assertTrue($this->cache->inCache('folder/foobar/2'));
|
$this->assertTrue($this->cache->inCache('folder/foobar/2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testGetIncomplete() {
|
||||||
|
$file1 = 'folder1';
|
||||||
|
$file2 = 'folder2';
|
||||||
|
$file3 = 'folder3';
|
||||||
|
$file4 = 'folder4';
|
||||||
|
$data = array('size' => 10, 'mtime' => 50, 'mimetype' => 'foo/bar');
|
||||||
|
|
||||||
|
$this->cache->put($file1, $data);
|
||||||
|
$data['size'] = -1;
|
||||||
|
$this->cache->put($file2, $data);
|
||||||
|
$this->cache->put($file3, $data);
|
||||||
|
$data['size'] = 12;
|
||||||
|
$this->cache->put($file4, $data);
|
||||||
|
|
||||||
|
$this->assertEquals($file3, $this->cache->getIncomplete());
|
||||||
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
$this->cache->clear();
|
$this->cache->clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue