Skip to content

Commit

Permalink
Find .nomedia and .noimage files by mimetype
Browse files Browse the repository at this point in the history
Signed-off-by: Arne Hamann <[email protected]>
  • Loading branch information
tacruc committed May 19, 2022
1 parent e69b3b4 commit 9bea343
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/Service/GeophotoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getAllFromDB(string $userId, bool $respectNomediaAndNoimage=true
* @param bool $respectNomediaAndNoimage
* @return array with geodatas of all nonLocalizedPhotos
*/
public function getNonLocalizedFromDB (string $userId, bool $respectNomediaAndNoimage=true) {
public function getNonLocalizedFromDB (string $userId, bool $respectNomediaAndNoimage=true): array {
$ignoredPaths = $respectNomediaAndNoimage ? $this->getIgnoredPaths($userId) : [];
$foo = $this->loadTimeorderedPointSets($userId);
$photoEntities = $this->photoMapper->findAllNonLocalized($userId);
Expand Down Expand Up @@ -199,14 +199,12 @@ public function getNonLocalizedFromDB (string $userId, bool $respectNomediaAndNo
/**
* @return array
*/
private function getIgnoredPaths($userId){
private function getIgnoredPaths($userId): array {
$ignoredPaths = [];
$userFolder = $this->root->getUserFolder($userId);
$excludedNodes = $userFolder->search(new SearchQuery(
new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
new SearchBinaryOperator( ISearchBinaryOperator::OPERATOR_NOT, [
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', FileInfo::TYPE_FOLDER)
]),
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'application/octet-stream'),
new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.nomedia'),
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.noimage'),
Expand All @@ -224,10 +222,11 @@ private function getIgnoredPaths($userId){

/**
* returns a array of locations for a given date
* @param $dateTaken
*
* @param $dateTaken int
* @return array
*/
private function getLocationGuesses($dateTaken) {
private function getLocationGuesses(int $dateTaken): array {
$locations = [];
foreach (($this->timeorderedPointSets ?? []) as $timeordedPointSet) {
$location = $this->getLocationFromSequenceOfPoints($dateTaken,$timeordedPointSet);
Expand Down Expand Up @@ -273,7 +272,7 @@ private function loadTimeorderedPointSets($userId) {
* @param $content
* @return array
*/
private function getTracksFromGPX($content) {
private function getTracksFromGPX($content): array {
$tracks = [];
$gpx = simplexml_load_string($content);
foreach ($gpx->trk as $trk) {
Expand All @@ -287,7 +286,7 @@ private function getTracksFromGPX($content) {
* @param $track
* @return array
*/
private function getTimeorderdPointsFromTrack($track) {
private function getTimeorderdPointsFromTrack($track): array {
$points = [];
foreach ($track->trkseg as $seg) {
foreach ($seg->trkpt as $pt) {
Expand All @@ -303,10 +302,10 @@ private function getTimeorderdPointsFromTrack($track) {
}

/**
* @param $dateTaken date of the picture
* @param $dateTaken int timestamp of the picture
* @param $points array sorted by keys timestamp => [lat, lng]
*/
private function getLocationFromSequenceOfPoints($dateTaken, $points) {
private function getLocationFromSequenceOfPoints(int $dateTaken, array $points): ?array {
$foo = end($points);
$end = key($points);
$foo = reset($points);
Expand Down Expand Up @@ -335,7 +334,7 @@ private function getLocationFromSequenceOfPoints($dateTaken, $points) {
}
}

private function getPreviewEnabledMimetypes() {
private function getPreviewEnabledMimetypes(): array {
$enabledMimeTypes = [];
foreach (PhotofilesService::PHOTO_MIME_TYPES as $mimeType) {
if ($this->preview->isMimeSupported($mimeType)) {
Expand Down

0 comments on commit 9bea343

Please sign in to comment.