31
31
use Psr \Log \LoggerInterface ;
32
32
33
33
require_once __DIR__ . '/../../vendor/autoload.php ' ;
34
+
34
35
use lsolesen \pel \PelDataWindow ;
35
36
use lsolesen \pel \PelEntryAscii ;
36
37
use lsolesen \pel \PelEntryRational ;
@@ -71,17 +72,17 @@ public function __construct(
71
72
$ this ->backgroundJobCache = $ this ->cacheFactory ->createDistributed ('maps:background-jobs ' );
72
73
}
73
74
74
- public function rescan ($ userId , $ inBackground= true , $ pathToScan= null ) {
75
+ public function rescan ($ userId , $ inBackground = true , $ pathToScan = null ) {
75
76
$ this ->photosCache ->clear ($ userId );
76
- $ userFolder = $ this ->root ->getUserFolder ($ userId );
77
- if ($ pathToScan === null ) {
78
- $ folder = $ userFolder ;
79
- $ this ->photoMapper ->deleteAll ($ userId );
80
- } else {
81
- $ folder = $ userFolder ->get ($ pathToScan );
82
- }
83
- $ photos = $ this ->gatherPhotoFiles ($ folder , true );
84
- foreach ($ photos as $ photo ) {
77
+ $ userFolder = $ this ->root ->getUserFolder ($ userId );
78
+ if ($ pathToScan === null ) {
79
+ $ folder = $ userFolder ;
80
+ $ this ->photoMapper ->deleteAll ($ userId );
81
+ } else {
82
+ $ folder = $ userFolder ->get ($ pathToScan );
83
+ }
84
+ $ photos = $ this ->gatherPhotoFiles ($ folder , true );
85
+ foreach ($ photos as $ photo ) {
85
86
if ($ inBackground ) {
86
87
$ this ->addPhoto ($ photo , $ userId );
87
88
} else {
@@ -409,7 +410,7 @@ private function gatherPhotoFiles($folder, $recursive) {
409
410
}
410
411
try {
411
412
$ notes = array_merge ($ notes , $ this ->gatherPhotoFiles ($ node , $ recursive ));
412
- } catch (\OCP \Files \StorageNotAvailableException | \Exception $ e ) {
413
+ } catch (\OCP \Files \StorageNotAvailableException | \Exception $ e ) {
413
414
$ msg = 'WARNING: Could not access ' . $ node ->getName ();
414
415
echo ($ msg . "\n" );
415
416
$ this ->logger ->error ($ msg );
@@ -447,12 +448,12 @@ private function getExif($file) : ?ExifGeoData {
447
448
$ exif_geo_data ->validate (true );
448
449
} catch (ExifDataInvalidException $ e ) {
449
450
$ exif_geo_data = null ;
450
- $ this ->logger ->notice ($ e ->getMessage (), ['code ' => $ e ->getCode (),'path ' => $ path ]);
451
+ $ this ->logger ->notice ($ e ->getMessage (), ['code ' => $ e ->getCode (), 'path ' => $ path ]);
451
452
} catch (ExifDataNoLocationException $ e ) {
452
- $ this ->logger ->notice ($ e ->getMessage (), ['code ' => $ e ->getCode (),'path ' => $ path ]);
453
+ $ this ->logger ->notice ($ e ->getMessage (), ['code ' => $ e ->getCode (), 'path ' => $ path ]);
453
454
} catch (\Throwable $ f ) {
454
455
$ exif_geo_data = null ;
455
- $ this ->logger ->error ($ f ->getMessage (), ['code ' => $ f ->getCode (),'path ' => $ path ]);
456
+ $ this ->logger ->error ($ f ->getMessage (), ['code ' => $ f ->getCode (), 'path ' => $ path ]);
456
457
}
457
458
return $ exif_geo_data ;
458
459
}
@@ -524,19 +525,25 @@ private function setGeolocation($pelSubIfdGps, $latitudeDegreeDecimal, $longitud
524
525
= $ this ->degreeDecimalToDegreeMinuteSecond (abs ($ longitudeDegreeDecimal ));
525
526
526
527
$ pelSubIfdGps ->addEntry (new PelEntryAscii (
527
- PelTag::GPS_LATITUDE_REF , $ latitudeRef ));
528
+ PelTag::GPS_LATITUDE_REF ,
529
+ $ latitudeRef
530
+ ));
528
531
$ pelSubIfdGps ->addEntry (new PelEntryRational (
529
532
PelTag::GPS_LATITUDE ,
530
533
[$ latitudeDegreeMinuteSecond ['degree ' ], 1 ],
531
534
[$ latitudeDegreeMinuteSecond ['minute ' ], 1 ],
532
- [round ($ latitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]));
535
+ [round ($ latitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]
536
+ ));
533
537
$ pelSubIfdGps ->addEntry (new PelEntryAscii (
534
- PelTag::GPS_LONGITUDE_REF , $ longitudeRef ));
538
+ PelTag::GPS_LONGITUDE_REF ,
539
+ $ longitudeRef
540
+ ));
535
541
$ pelSubIfdGps ->addEntry (new PelEntryRational (
536
542
PelTag::GPS_LONGITUDE ,
537
543
[$ longitudeDegreeMinuteSecond ['degree ' ], 1 ],
538
544
[$ longitudeDegreeMinuteSecond ['minute ' ], 1 ],
539
- [round ($ longitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]));
545
+ [round ($ longitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]
546
+ ));
540
547
}
541
548
542
549
private function degreeDecimalToDegreeMinuteSecond ($ degreeDecimal ) {
@@ -547,5 +554,4 @@ private function degreeDecimalToDegreeMinuteSecond($degreeDecimal) {
547
554
$ second = $ remainder * 60 ;
548
555
return ['degree ' => $ degree , 'minute ' => $ minute , 'second ' => $ second ];
549
556
}
550
-
551
557
}
0 commit comments