feat(indexing): allow to ignore dot and at starting files while indexing when wanted
parent
f042e1820c
commit
1a0aa8917e
|
@ -108,6 +108,31 @@ class Index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resolveValidFiles(array $nodes, array $mimes): array
|
||||||
|
{
|
||||||
|
return array_filter($nodes, static function ($node) use ($mimes) {
|
||||||
|
if (!$node instanceof File) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!\in_array($node->getMimeType(), $mimes, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fistChar = mb_substr($node->getName(), 0, 1);
|
||||||
|
|
||||||
|
if (SystemConfig::get('memories.index.ignore_file_with_starting_dot') && '.' === $fistChar) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SystemConfig::get('memories.index.ignore_file_with_starting_at') && '@' === $fistChar) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index all files in a folder.
|
* Index all files in a folder.
|
||||||
*
|
*
|
||||||
|
@ -129,7 +154,8 @@ class Index
|
||||||
|
|
||||||
// Filter files that are supported
|
// Filter files that are supported
|
||||||
$mimes = self::getMimeList();
|
$mimes = self::getMimeList();
|
||||||
$files = array_filter($nodes, static fn ($n) => $n instanceof File && \in_array($n->getMimeType(), $mimes, true));
|
|
||||||
|
$files = self::resolveValidFiles($nodes, $mimes);
|
||||||
|
|
||||||
// Create an associative array with file ID as key
|
// Create an associative array with file ID as key
|
||||||
$files = array_combine(array_map(static fn ($n) => $n->getId(), $files), $files);
|
$files = array_combine(array_map(static fn ($n) => $n->getId(), $files), $files);
|
||||||
|
|
|
@ -34,7 +34,10 @@ class SystemConfig
|
||||||
// Path to index (only used if indexing mode is 3)
|
// Path to index (only used if indexing mode is 3)
|
||||||
'memories.index.path' => '/',
|
'memories.index.path' => '/',
|
||||||
|
|
||||||
'memories.index.ignore_file_with_starting_dot' => false,
|
// To not index hidden files
|
||||||
|
'memories.index.ignore_file_with_starting_dot' => true,
|
||||||
|
|
||||||
|
// Some NAS use `@Recyle` to store deleted folders and files.
|
||||||
'memories.index.ignore_file_with_starting_at' => false,
|
'memories.index.ignore_file_with_starting_at' => false,
|
||||||
|
|
||||||
// Places database type identifier
|
// Places database type identifier
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
@update:checked="update('memories.index.ignore_file_with_starting_dot')"
|
@update:checked="update('memories.index.ignore_file_with_starting_dot')"
|
||||||
type="switch"
|
type="switch"
|
||||||
>
|
>
|
||||||
{{ t('memories', `Ignore files and folders starting with "."`) }}
|
{{ t('memories', `Ignore Hidden files and folders (starting with ".")`) }}
|
||||||
|
|
||||||
</NcCheckboxRadioSwitch>
|
</NcCheckboxRadioSwitch>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue