index: support .nomemories (fix #777)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/783/head
Varun Patil 2023-08-20 09:42:04 -07:00
parent ca8fad3055
commit 0091fdd962
7 changed files with 16 additions and 8 deletions

View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- **Feature**: Allow disabling autoplay of live photo ([#591](https://github.com/pulsejet/memories/issues/591))
- **Feature**: Improved layout for albums list view
- **Feature**: Improvements in admin interface
- **Feature**: A `.nomemories` file will now hide a folder from Memories without affecting other apps ([#777](https://github.com/pulsejet/memories/issues/777))
- **Bugfix**: You can now configure the transpose strategy of the transcoder (required for QSV)
## [v5.2.1] - 2023-07-03

View File

@ -161,7 +161,7 @@ class MigrateGoogleTakeout extends Command
protected function migrateFolder(Folder $folder): void
{
// Check for .nomedia
if ($folder->nodeExists('.nomedia')) {
if ($folder->nodeExists('.nomedia') || $folder->nodeExists('.nomemories')) {
return;
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace OCA\Memories\Db;
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OCA\Memories\Exceptions;
@ -31,6 +32,7 @@ use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use OCP\ICache;
use OCP\ICacheFactory;
@ -152,10 +154,13 @@ class FsManager
return $paths;
}
$comp = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.nomedia');
$comp = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.nomedia'),
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.nomemories'),
]);
$search = $root->search(new SearchQuery($comp, 0, 0, [], Util::getUser()));
$paths = array_map(fn (Node $node) => \dirname($node->getPath()), $search);
$paths = array_unique(array_map(fn (Node $node) => \dirname($node->getPath()), $search));
$this->nomediaCache->set($key, $paths, 60 * 60); // 1 hour
return $paths;

View File

@ -21,7 +21,9 @@ trait TimelineQueryCTE
$CLS_TOP_FOLDER = 'f.fileid IN (:topFolderIds)';
// Select 1 if there is a .nomedia file in the folder
$SEL_NOMEDIA = "SELECT 1 FROM *PREFIX*filecache f2 WHERE f2.parent = f.fileid AND f2.name = '.nomedia'";
$SEL_NOMEDIA = "SELECT 1 FROM *PREFIX*filecache f2
WHERE (f2.parent = f.fileid)
AND (f2.name = '.nomedia' OR f2.name = '.nomemories')";
// Check no nomedia file exists in the folder
$CLS_NOMEDIA = "NOT EXISTS ({$SEL_NOMEDIA})";

View File

@ -60,7 +60,7 @@ class PostWriteListener implements IEventListener
try {
$parent = $node;
while ($parent = $parent->getParent()) {
if ($parent->nodeExists('.nomedia')) {
if ($parent->nodeExists('.nomedia') || $parent->nodeExists('.nomemories')) {
return;
}
}

View File

@ -120,8 +120,8 @@ class Index
*/
public function indexFolder(Folder $folder): void
{
if ($folder->nodeExists('.nomedia')) {
$this->log("Skipping folder {$folder->getPath()} due to .nomedia file\n", true);
if ($folder->nodeExists('.nomedia') || $folder->nodeExists('.nomemories')) {
$this->log("Skipping folder {$folder->getPath()} due to .nomedia or .nomemories file\n", true);
return;
}

View File

@ -56,7 +56,7 @@
'The EXIF indexes are built and checked in a periodic background task. Be careful when selecting anything other than automatic indexing. For example, setting the indexing to only timeline folders may cause delays before media becomes available to users, since the user configures the timeline only after logging in.'
)
}}
{{ t('memories', 'Folders with a ".nomedia" file are always excluded from indexing.') }}
{{ t('memories', 'Folders with a ".nomedia" or a ".nomemories" file are always excluded from indexing.') }}
<NcCheckboxRadioSwitch
:checked.sync="config['memories.index.mode']"
value="1"