|
|
|
@ -44,6 +44,11 @@ class Scanner extends BasicEmitter { |
|
|
|
|
*/ |
|
|
|
|
protected $cacheActive; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @var bool $useTransactions whether to use transactions |
|
|
|
|
*/ |
|
|
|
|
protected $useTransactions = true; |
|
|
|
|
|
|
|
|
|
const SCAN_RECURSIVE = true; |
|
|
|
|
const SCAN_SHALLOW = false; |
|
|
|
|
|
|
|
|
@ -57,6 +62,16 @@ class Scanner extends BasicEmitter { |
|
|
|
|
$this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Whether to wrap the scanning of a folder in a database transaction |
|
|
|
|
* On default transactions are used |
|
|
|
|
* |
|
|
|
|
* @param bool $useTransactions |
|
|
|
|
*/ |
|
|
|
|
public function setUseTransactions($useTransactions) { |
|
|
|
|
$this->useTransactions = $useTransactions; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* get all the metadata of a file or folder |
|
|
|
|
* * |
|
|
|
@ -234,7 +249,9 @@ class Scanner extends BasicEmitter { |
|
|
|
|
$newChildren = array(); |
|
|
|
|
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) { |
|
|
|
|
$exceptionOccurred = false; |
|
|
|
|
\OC_DB::beginTransaction(); |
|
|
|
|
if ($this->useTransactions) { |
|
|
|
|
\OC_DB::beginTransaction(); |
|
|
|
|
} |
|
|
|
|
if (is_resource($dh)) { |
|
|
|
|
while (($file = readdir($dh)) !== false) { |
|
|
|
|
$child = ($path) ? $path . '/' . $file : $file; |
|
|
|
@ -266,7 +283,9 @@ class Scanner extends BasicEmitter { |
|
|
|
|
$child = ($path) ? $path . '/' . $childName : $childName; |
|
|
|
|
$this->removeFromCache($child); |
|
|
|
|
} |
|
|
|
|
\OC_DB::commit(); |
|
|
|
|
if ($this->useTransactions) { |
|
|
|
|
\OC_DB::commit(); |
|
|
|
|
} |
|
|
|
|
if ($exceptionOccurred) { |
|
|
|
|
// It might happen that the parallel scan process has already |
|
|
|
|
// inserted mimetypes but those weren't available yet inside the transaction |
|
|
|
|