protected function collectFiles()
{
$table = \FilesModel::getTable();
$conditions = array();
$parameters = array();
if (count($this->pendingIds)) {
$conditions[] = $table . '.uuid IN(' . implode(',', array_fill(0, count($this->pendingIds), 'UNHEX(?)')) . ')';
$parameters = array_map('bin2hex', $this->pendingIds);
$this->pendingIds = array();
}
if (count($this->pendingPaths)) {
$slug = $table . '.path LIKE ?';
foreach ($this->pendingPaths as $pendingPath) {
$conditions[] = $slug;
$parameters[] = $pendingPath . '%';
}
$this->pendingPaths = array();
}
if (!count($conditions)) {
return;
}
if ($files = \FilesModel::findBy(array(implode(' OR ', $conditions)), $parameters)) {
$this->addFileModels($files);
}
if (count($this->pendingPaths)) {
// Run again.
$this->collectFiles();
}
}