Skip to content

Commit

Permalink
Merge branch 'main' into platform-check-fix
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr authored Apr 17, 2024
2 parents 196265e + 92dc6c9 commit 7219bb4
Show file tree
Hide file tree
Showing 12 changed files with 909 additions and 1,011 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ Recognize uses
- Processor: x86 64-bit, arm64, armv7l (no AVX needed)
- System with glibc or musl (incl. Alpine linux and thus also Nextcloud AIO)
- ~4GB of free RAM (if you're cutting it close, make sure you have some swap available)
- This app is currently incompatible with the *Suspicious Login* app due to a dependency conflict (ie. you can only have one of the two installed)

#### Tmp
This app temporarily stores files to be recognized in /tmp. If you're using docker, you might find
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJobs/StorageCrawlJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(ITimeFactory $timeFactory, Logger $logger, QueueServ
}

/**
* @param array{storage_id:int, root_id:int, override_root:int, last_file_id:int} $argument
* @param array{storage_id:int, root_id:int, override_root:int, last_file_id:int, models?: list<string>} $argument
* @return void
*/
protected function run($argument): void {
Expand Down
2 changes: 1 addition & 1 deletion lib/Classifiers/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract public function classify(array $queueFiles): void;
* @param QueueFile[] $queueFiles
* @param int $timeout
* @return \Generator
* @psalm-return \Generator<QueueFile, mixed, mixed, void>
* @psalm-return \Generator<QueueFile, mixed, mixed, null>
* @throws \ErrorException|\RuntimeException
*/
public function classifyFiles(string $model, array $queueFiles, int $timeout): \Generator {
Expand Down
3 changes: 3 additions & 0 deletions lib/Db/FaceClusterMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;

/**
* @psalm-extends QBMapper<FaceCluster>
*/
class FaceClusterMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'recognize_face_clusters', FaceCluster::class);
Expand Down
3 changes: 3 additions & 0 deletions lib/Db/FaceDetectionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use OCP\IConfig;
use OCP\IDBConnection;

/**
* @psalm-extends QBMapper<FaceDetection>
*/
class FaceDetectionMapper extends QBMapper {
private IConfig $config;

Expand Down
3 changes: 3 additions & 0 deletions lib/Db/QueueMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;

/**
* @psalm-extends QBMapper<QueueFile>
*/
class QueueMapper extends QBMapper {
public const MODELS = [
ImagenetClassifier::MODEL_NAME,
Expand Down
2 changes: 1 addition & 1 deletion lib/Helper/TAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function getFolder($path) {
}
if (substr($file, 0, $pathLength) == $path and $file != $path) {
$result = substr($file, $pathLength);
if ($pos = strpos($result, '/')) {
if (($pos = strpos($result, '/')) !== false) {
$result = substr($result, 0, $pos + 1);
}
if (array_search($result, $folderContent) === false) {
Expand Down
5 changes: 4 additions & 1 deletion lib/Hooks/FileListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;

/**
* @psalm-implements IEventListener<Event>
*/
class FileListener implements IEventListener {
private FaceDetectionMapper $faceDetectionMapper;
private LoggerInterface $logger;
Expand Down Expand Up @@ -70,7 +73,7 @@ public function handle(Event $event): void {
$node = $share->getNode();

$accessList = $this->shareManager->getAccessList($node, true, true);
$userIds = array_map(fn ($id) => (string)$id, array_keys($accessList['users']));
$userIds = array_map(fn (int|string $id) => (string)$id, array_keys($accessList['users']));

if ($node->getType() === FileInfo::TYPE_FOLDER) {
$mount = $node->getMountPoint();
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FaceClusterAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function calculateClusters(string $userId, int $batchSize = 0): void {
/** @var int[] $detectionKeys */
$detectionKeys = array_keys($flatCluster->getClusterVertices());

$clusterDetections = array_filter($detections, function (int $key) use ($detectionKeys) {
$clusterDetections = array_filter($detections, function ($key) use ($detectionKeys) {
return isset($detectionKeys[$key]);
}, ARRAY_FILTER_USE_KEY);
$clusterCentroid = self::calculateCentroidOfDetections($clusterDetections);
Expand Down
Loading

0 comments on commit 7219bb4

Please sign in to comment.