36
36
use OCP \Files \IRootFolder ;
37
37
use OCP \AppFramework \Db \DoesNotExistException ;
38
38
use OCP \AppFramework \Db \MultipleObjectsReturnedException ;
39
+ use OCP \IL10N ;
39
40
use Psr \Log \LoggerInterface ;
40
41
use OCP \BackgroundJob \IJobList ;
41
42
use OCP \Files \NotFoundException ;
@@ -99,6 +100,7 @@ class CollectorService {
99
100
public const TASK_TYPE_MANUAL = 'manual ' ;
100
101
public const TASK_TYPE_AUTO = 'auto ' ;
101
102
public const TASK_TYPE_QUEUED = 'queued ' ;
103
+ private IL10N $ l10n ;
102
104
103
105
104
106
public function __construct (
@@ -113,7 +115,8 @@ public function __construct(
113
115
VideosService $ videosService ,
114
116
IJobList $ jobList ,
115
117
IPreview $ previewManager ,
116
- CPAUtilsService $ cpaUtils
118
+ CPAUtilsService $ cpaUtils ,
119
+ IL10N $ l10n ,
117
120
) {
118
121
if ($ userId !== null ) {
119
122
$ this ->userId = $ userId ;
@@ -129,6 +132,7 @@ public function __construct(
129
132
$ this ->videosService = $ videosService ;
130
133
$ this ->jobList = $ jobList ;
131
134
$ this ->previewManager = $ previewManager ;
135
+ $ this ->l10n = $ l10n ;
132
136
}
133
137
134
138
/**
@@ -228,6 +232,10 @@ public function restartTask(array $params = []) {
228
232
$ this ->terminate ($ taskId );
229
233
230
234
if ($ taskData ['files_total ' ] > 0 ) {
235
+ if (!isset ($ collectorSettings ['exif_transpose ' ])) {
236
+ $ ignoreOrientationSetting = $ this ->settingsMapper ->findByName ('ignore_orientation ' );
237
+ $ collectorSettings ['exif_transpose ' ] = !json_decode ($ ignoreOrientationSetting ->getValue ());
238
+ }
231
239
$ collectorTask ->setTargetDirectoryIds (json_encode ($ targetDirectoryIds ));
232
240
$ collectorTask ->setExcludeList (json_encode ($ excludeList ));
233
241
$ collectorTask ->setCollectorSettings (json_encode ($ collectorSettings ));
@@ -342,8 +350,10 @@ public function duplicate($taskId): ?CollectorTask {
342
350
'hash_size ' => $ collectorSettings ['hash_size ' ],
343
351
'target_mtype ' => $ collectorSettings ['target_mtype ' ],
344
352
'finish_notification ' => $ collectorSettings ['finish_notification ' ],
353
+ 'exif_transpose ' => $ collectorSettings ['exif_transpose ' ] ?? true ,
345
354
],
346
355
'excludeList ' => json_decode ($ collectorTask ->getExcludeList (), true ),
356
+ 'name ' => '[ ' . $ this ->l10n ->t ('duplicated ' ) . '] ' . $ collectorTask ->getName (),
347
357
]);
348
358
return $ duplicatedCollectorTask ;
349
359
}
@@ -362,6 +372,8 @@ public function createCollectorTask(array $params = [], bool $queued = false): ?
362
372
$ pyThresholdSetting = $ this ->settingsMapper ->findByName ('similarity_threshold ' );
363
373
/** @var Setting */
364
374
$ pyHashSizeSetting = $ this ->settingsMapper ->findByName ('hash_size ' );
375
+ /** @var Setting */
376
+ $ ignoreOrientationSetting = $ this ->settingsMapper ->findByName ('ignore_orientation ' );
365
377
} else {
366
378
/** @var string */
367
379
$ pyAlgorithmSetting = $ params ['collectorSettings ' ]['hashing_algorithm ' ];
@@ -370,6 +382,8 @@ public function createCollectorTask(array $params = [], bool $queued = false): ?
370
382
/** @var string */
371
383
$ pyHashSizeSetting = $ params ['collectorSettings ' ]['hash_size ' ];
372
384
/** @var Setting */
385
+ $ ignoreOrientationSetting = $ this ->settingsMapper ->findByName ('ignore_orientation ' );
386
+ /** @var Setting */
373
387
$ excludeListSetting = $ this ->settingsMapper ->findByName ('exclude_list ' );
374
388
$ excludeList = count ($ params ) === 0 ? [
375
389
'admin ' => $ excludeListSetting ->getValue (),
@@ -404,6 +418,7 @@ public function createCollectorTask(array $params = [], bool $queued = false): ?
404
418
'finish_notification ' => count ($ params ) === 0
405
419
? true : $ params ['collectorSettings ' ]['finish_notification ' ],
406
420
'duplicated ' => isset ($ params ['type ' ]) && $ params ['type ' ] === 'duplicated ' ,
421
+ 'exif_transpose ' => count ($ params ) === 0 ? $ ignoreOrientationSetting ->getValue () : $ params ['collectorSettings ' ]['exif_transpose ' ],
407
422
]),
408
423
'filesScanned ' => 0 ,
409
424
'filesTotal ' => count ($ params ) === 0
0 commit comments