Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.3.8 maintenance #212

Merged
merged 12 commits into from
Dec 14, 2023
24 changes: 12 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Test

on:
pull_request:
branches:
- main
- dev
paths-ignore:
- l10n/**
push:
branches:
- main
- dev
paths-ignore:
- l10n/**
# pull_request:
# branches:
# - main
# - dev
# paths-ignore:
# - l10n/**
# push:
# branches:
# - main
# - dev
# paths-ignore:
# - l10n/**
workflow_dispatch:

env:
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file.

## [0.3.8 - 2023-12-14]

Maintenance update.
[`cloud_py_api`](https://github.com/cloud-py-api/cloud_py_api) is **required** to be installed
(or updated) and enabled first.

### Added

- Added task name of target folder for tasks created via file action
- Added EXIF transpose option (https://github.com/cloud-py-api/mediadc/issues/199)

### Fixed

- Fixed duplicate task action does not copy task name
- Fixed translatable strings for notification

### Updated

- Updated packages (security fixes, NC28 support)
- Updated l10n (localization)
- Update files plugin (NC28 support)

## [0.3.7 - 2023-10-08]

Maintenance update.
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This app allows to find duplicate or similar 📸📹 photos and videos
Quick start guide and further information in our [Wiki](https://github.com/cloud-py-api/mediadc/wiki).
]]>
</description>
<version>0.3.7</version>
<version>0.3.8</version>
<licence>agpl</licence>
<author mail="andrey18106x@gmail.com" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
<author mail="bigcat88@icloud.com" homepage="https://github.com/bigcat88">Alexander Piskun</author>
Expand Down
3 changes: 2 additions & 1 deletion lib/Command/CollectorTaskNotificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function configure(): void {
protected function execute(InputInterface $input, OutputInterface $output): int {
$taskId = $input->getArgument(self::ARGUMENT_TASK_ID);
$status = $input->getArgument(self::ARGUMENT_TASK_STATUS);
/** @var CollectorTask */
/** @var CollectorTask $collectorTask */
$collectorTask = $this->tasksMapper->find(intval($taskId));
$detailGroups = array_map(function ($d) {
$d['files'] = explode(',', $d['files']);
Expand Down Expand Up @@ -103,6 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'status' => $status,
'duplicate-groups' => count($detailGroups),
'duplicates' => $duplicates,
'name' => $collectorTask->getName(),
]);
$this->notificationManager->notify($notification);
return 0;
Expand Down
8 changes: 8 additions & 0 deletions lib/Migration/data/AppInitialData.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class AppInitialData {
"displayName" => "Use pre-compiled Python binaries",
"description" => "Use Python part in binary format (located in the appdata folder)"
],
[
"name" => "ignore_orientation",
"value" => false,
"displayName" => "Ignore EXIF image orientation",
"description" => "Enable to allow detection of mirrored images as duplicates"
],
]
];

Expand All @@ -92,5 +98,7 @@ private function _stringsForL10N(): void {
$this->l10n->t("Global administrator's exclude list that applies to each task");
$this->l10n->t("Use pre-compiled Python binaries");
$this->l10n->t("Use Python part in binary format (located in the appdata folder)");
$this->l10n->t("Ignore EXIF image orientation");
$this->l10n->t("Enable to allow detection of mirrored images as duplicates");
}
}
11 changes: 9 additions & 2 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ public function prepare(INotification $notification, string $languageCode): INot

$parameters = $notification->getSubjectParameters();
if ($parameters['status'] === 'finished') {
$notification->setRichSubject($l->t('Task successfully finished, found ' . $parameters['duplicate-groups'] . ' duplicate group(s) (' . $parameters['duplicates'] . ' file(s))'));
if (isset($parameters['name']) && $parameters['name'] !== '') {
$message = $l->t('Task "%s" successfully finished.', [$parameters['name']]);
} else {
$message = $l->t('Task successfully finished.');
}
$filesMessage = $l->n('%n file', '%n files', $parameters['duplicates']);
$message .= ' ' . $l->n('Found %n duplicate group', 'Found %n duplicate groups', $parameters['duplicate-groups']) . ' (' . $filesMessage . ')';
$notification->setRichSubject($message);
} else {
$notification->setRichSubject($l->t('Task finished with status "' . $parameters['status'] . '".'));
$notification->setRichSubject($l->t('Task finished with status {status}', ['status' => $parameters['status']]));
}
$notification->setRichMessage($l->t('Task finished, check out results'));
$notification->setParsedSubject($l->t('Task finished, check out results'));
Expand Down
17 changes: 16 additions & 1 deletion lib/Service/CollectorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCP\Files\IRootFolder;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\IL10N;
use Psr\Log\LoggerInterface;
use OCP\BackgroundJob\IJobList;
use OCP\Files\NotFoundException;
Expand Down Expand Up @@ -99,6 +100,7 @@ class CollectorService {
public const TASK_TYPE_MANUAL = 'manual';
public const TASK_TYPE_AUTO = 'auto';
public const TASK_TYPE_QUEUED = 'queued';
private IL10N $l10n;


public function __construct(
Expand All @@ -113,7 +115,8 @@ public function __construct(
VideosService $videosService,
IJobList $jobList,
IPreview $previewManager,
CPAUtilsService $cpaUtils
CPAUtilsService $cpaUtils,
IL10N $l10n,
) {
if ($userId !== null) {
$this->userId = $userId;
Expand All @@ -129,6 +132,7 @@ public function __construct(
$this->videosService = $videosService;
$this->jobList = $jobList;
$this->previewManager = $previewManager;
$this->l10n = $l10n;
}

/**
Expand Down Expand Up @@ -228,6 +232,10 @@ public function restartTask(array $params = []) {
$this->terminate($taskId);

if ($taskData['files_total'] > 0) {
if (!isset($collectorSettings['exif_transpose'])) {
$ignoreOrientationSetting = $this->settingsMapper->findByName('ignore_orientation');
$collectorSettings['exif_transpose'] = !json_decode($ignoreOrientationSetting->getValue());
}
$collectorTask->setTargetDirectoryIds(json_encode($targetDirectoryIds));
$collectorTask->setExcludeList(json_encode($excludeList));
$collectorTask->setCollectorSettings(json_encode($collectorSettings));
Expand Down Expand Up @@ -342,8 +350,10 @@ public function duplicate($taskId): ?CollectorTask {
'hash_size' => $collectorSettings['hash_size'],
'target_mtype' => $collectorSettings['target_mtype'],
'finish_notification' => $collectorSettings['finish_notification'],
'exif_transpose' => $collectorSettings['exif_transpose'] ?? true,
],
'excludeList' => json_decode($collectorTask->getExcludeList(), true),
'name' => '[' . $this->l10n->t('duplicated') . '] ' . $collectorTask->getName(),
]);
return $duplicatedCollectorTask;
}
Expand All @@ -362,6 +372,8 @@ public function createCollectorTask(array $params = [], bool $queued = false): ?
$pyThresholdSetting = $this->settingsMapper->findByName('similarity_threshold');
/** @var Setting */
$pyHashSizeSetting = $this->settingsMapper->findByName('hash_size');
/** @var Setting */
$ignoreOrientationSetting = $this->settingsMapper->findByName('ignore_orientation');
} else {
/** @var string */
$pyAlgorithmSetting = $params['collectorSettings']['hashing_algorithm'];
Expand All @@ -370,6 +382,8 @@ public function createCollectorTask(array $params = [], bool $queued = false): ?
/** @var string */
$pyHashSizeSetting = $params['collectorSettings']['hash_size'];
/** @var Setting */
$ignoreOrientationSetting = $this->settingsMapper->findByName('ignore_orientation');
/** @var Setting */
$excludeListSetting = $this->settingsMapper->findByName('exclude_list');
$excludeList = count($params) === 0 ? [
'admin' => $excludeListSetting->getValue(),
Expand Down Expand Up @@ -404,6 +418,7 @@ public function createCollectorTask(array $params = [], bool $queued = false): ?
'finish_notification' => count($params) === 0
? true : $params['collectorSettings']['finish_notification'],
'duplicated' => isset($params['type']) && $params['type'] === 'duplicated',
'exif_transpose' => count($params) === 0 ? $ignoreOrientationSetting->getValue() : $params['collectorSettings']['exif_transpose'],
]),
'filesScanned' => 0,
'filesTotal' => count($params) === 0
Expand Down
Loading
Loading