3131use Psr \Log \LoggerInterface ;
3232
3333require_once __DIR__ . '/../../vendor/autoload.php ' ;
34+
3435use lsolesen \pel \PelDataWindow ;
3536use lsolesen \pel \PelEntryAscii ;
3637use lsolesen \pel \PelEntryRational ;
@@ -71,17 +72,17 @@ public function __construct(
7172 $ this ->backgroundJobCache = $ this ->cacheFactory ->createDistributed ('maps:background-jobs ' );
7273 }
7374
74- public function rescan ($ userId , $ inBackground= true , $ pathToScan= null ) {
75+ public function rescan ($ userId , $ inBackground = true , $ pathToScan = null ) {
7576 $ 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 ) {
8586 if ($ inBackground ) {
8687 $ this ->addPhoto ($ photo , $ userId );
8788 } else {
@@ -409,7 +410,7 @@ private function gatherPhotoFiles($folder, $recursive) {
409410 }
410411 try {
411412 $ notes = array_merge ($ notes , $ this ->gatherPhotoFiles ($ node , $ recursive ));
412- } catch (\OCP \Files \StorageNotAvailableException | \Exception $ e ) {
413+ } catch (\OCP \Files \StorageNotAvailableException | \Exception $ e ) {
413414 $ msg = 'WARNING: Could not access ' . $ node ->getName ();
414415 echo ($ msg . "\n" );
415416 $ this ->logger ->error ($ msg );
@@ -447,12 +448,12 @@ private function getExif($file) : ?ExifGeoData {
447448 $ exif_geo_data ->validate (true );
448449 } catch (ExifDataInvalidException $ e ) {
449450 $ 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 ]);
451452 } 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 ]);
453454 } catch (\Throwable $ f ) {
454455 $ 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 ]);
456457 }
457458 return $ exif_geo_data ;
458459 }
@@ -524,19 +525,25 @@ private function setGeolocation($pelSubIfdGps, $latitudeDegreeDecimal, $longitud
524525 = $ this ->degreeDecimalToDegreeMinuteSecond (abs ($ longitudeDegreeDecimal ));
525526
526527 $ pelSubIfdGps ->addEntry (new PelEntryAscii (
527- PelTag::GPS_LATITUDE_REF , $ latitudeRef ));
528+ PelTag::GPS_LATITUDE_REF ,
529+ $ latitudeRef
530+ ));
528531 $ pelSubIfdGps ->addEntry (new PelEntryRational (
529532 PelTag::GPS_LATITUDE ,
530533 [$ latitudeDegreeMinuteSecond ['degree ' ], 1 ],
531534 [$ latitudeDegreeMinuteSecond ['minute ' ], 1 ],
532- [round ($ latitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]));
535+ [round ($ latitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]
536+ ));
533537 $ pelSubIfdGps ->addEntry (new PelEntryAscii (
534- PelTag::GPS_LONGITUDE_REF , $ longitudeRef ));
538+ PelTag::GPS_LONGITUDE_REF ,
539+ $ longitudeRef
540+ ));
535541 $ pelSubIfdGps ->addEntry (new PelEntryRational (
536542 PelTag::GPS_LONGITUDE ,
537543 [$ longitudeDegreeMinuteSecond ['degree ' ], 1 ],
538544 [$ longitudeDegreeMinuteSecond ['minute ' ], 1 ],
539- [round ($ longitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]));
545+ [round ($ longitudeDegreeMinuteSecond ['second ' ] * 1000 ), 1000 ]
546+ ));
540547 }
541548
542549 private function degreeDecimalToDegreeMinuteSecond ($ degreeDecimal ) {
@@ -547,5 +554,4 @@ private function degreeDecimalToDegreeMinuteSecond($degreeDecimal) {
547554 $ second = $ remainder * 60 ;
548555 return ['degree ' => $ degree , 'minute ' => $ minute , 'second ' => $ second ];
549556 }
550-
551557}
0 commit comments