Skip to content

Commit

Permalink
Merge pull request #21 from eldertek/nightly
Browse files Browse the repository at this point in the history
Nightly v1.0.9
  • Loading branch information
eldertek authored Nov 1, 2023
2 parents eebafaf + 5439495 commit 1a0d987
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/duplicatefinder-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/duplicatefinder-settings.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lib/Service/FileInfoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@ class FileInfoService
private $folderService;
/** @var ScannerUtil */
private $scannerUtil;
/** @var FilterService */
private $filterService;

public function __construct(
FileInfoMapper $mapper,
IEventDispatcher $eventDispatcher,
LoggerInterface $logger,
ShareService $shareService,
FilterService $filterService,
FolderService $folderService,
ScannerUtil $scannerUtil
) {
$this->mapper = $mapper;
$this->eventDispatcher = $eventDispatcher;
$this->logger = $logger;
$this->shareService = $shareService;
$this->filterService = $filterService;
$this->folderService = $folderService;
$this->scannerUtil = $scannerUtil;
}
Expand Down Expand Up @@ -174,6 +178,7 @@ public function updateFileMeta(FileInfo $fileInfo, ?string $fallbackUID = null):
throw $e;
}
}
$fileInfo->setIgnored($this->filterService->isIgnored($fileInfo, $file));
return $fileInfo;
}

Expand Down
52 changes: 52 additions & 0 deletions lib/Service/FilterService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace OCA\DuplicateFinder\Service;

use Psr\Log\LoggerInterface;
use OCP\Files\Node;
use OCP\Files\NotFoundException;

use OCA\DuplicateFinder\Db\FileInfo;
use OCA\DuplicateFinder\Exception\ForcedToIgnoreFileException;
use OCA\DuplicateFinder\Service\ConfigService;

class FilterService
{
/** @var LoggerInterface */
private $logger;
/** @var ConfigService */
private $config;

public function __construct(
LoggerInterface $logger,
ConfigService $config
) {
$this->logger = $logger;
$this->config = $config;
}

public function isIgnored(FileInfo $fileInfo, Node $node): bool
{
// Ignore mounted files
if ($node->isMounted() && $this->config->areMountedFilesIgnored()) {
throw new ForcedToIgnoreFileException($fileInfo, 'app:ignore_mounted_files');
}

// Ignore files when any ancestor folder contains a .nodupefinder file
while ($node !== null) {
try {
$parent = $node->getParent();
if ($parent !== null && $parent->nodeExists('.nodupefinder')) {
return true;
}
$node = $parent; // move up to the parent and check again
} catch (NotFoundException $e) {
// No parent found (probably root), break the loop
break;
}
}

return false;
}

}
1 change: 1 addition & 0 deletions lib/Utils/ScannerUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ private function showOutput(string $message, bool $isVerbose = false) : void
$isVerbose ? OutputInterface::VERBOSITY_VERBOSE : OutputInterface::VERBOSITY_NORMAL
);
}

}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a0d987

Please sign in to comment.