diff --git a/CHANGELOG.md b/CHANGELOG.md index c3d88dbc1..808df6b4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## 1.6.0 - 2024.12.31 Scan photos of specific directory +## 1.6.0 - [unreleased] +### Added - Scan photos of specific directory [#1231](https://github.com/nextcloud/maps/pull/1231) @tetebueno + +### Fixed +- Georeferenced photos from external folders not shown on map + [#1371](https://github.com/nextcloud/maps/issues/1371) @umgfoin +- Fix wrong failure-msg. when clearing photo-cache + [#1375](https://github.com/nextcloud/maps/pull/1375) @umgfoin ## 1.5.0 - 2024.11.16 Nextcloud Hub 9 diff --git a/l10n/lt_LT.js b/l10n/lt_LT.js index 2a9a14cd7..e6905a6e9 100644 --- a/l10n/lt_LT.js +++ b/l10n/lt_LT.js @@ -23,9 +23,9 @@ OC.L10N.register( "Category name" : "Kategorijos pavadinimas", "Rename" : "Pervadinti", "Add a favorite" : "Pridėti mėgstamą", - "Delete share link" : "Ištrinti bendrinimo nuorodą", + "Delete share link" : "Ištrinti viešinio nuorodą", "Copied!" : "Nukopijuota!", - "Copy share link" : "Kopijuoti bendrinimo nuorodą", + "Copy share link" : "Kopijuoti viešinio nuorodą", "Cancel" : "Atsisakyti", "Link copied" : "Nuoroda nukopijuota", "Link could not be copied to clipboard." : "Nepavyko nukopijuoti nuorodos į iškarpinę.", diff --git a/l10n/lt_LT.json b/l10n/lt_LT.json index 66a911ec4..8d492505a 100644 --- a/l10n/lt_LT.json +++ b/l10n/lt_LT.json @@ -21,9 +21,9 @@ "Category name" : "Kategorijos pavadinimas", "Rename" : "Pervadinti", "Add a favorite" : "Pridėti mėgstamą", - "Delete share link" : "Ištrinti bendrinimo nuorodą", + "Delete share link" : "Ištrinti viešinio nuorodą", "Copied!" : "Nukopijuota!", - "Copy share link" : "Kopijuoti bendrinimo nuorodą", + "Copy share link" : "Kopijuoti viešinio nuorodą", "Cancel" : "Atsisakyti", "Link copied" : "Nuoroda nukopijuota", "Link could not be copied to clipboard." : "Nepavyko nukopijuoti nuorodos į iškarpinę.", diff --git a/l10n/pt_PT.js b/l10n/pt_PT.js index 06f79c514..e974c0045 100644 --- a/l10n/pt_PT.js +++ b/l10n/pt_PT.js @@ -52,6 +52,7 @@ OC.L10N.register( "Not grouped" : "Não agrupados", "Default" : "Predefinido", "Failed to save settings" : "Erro ao gravar as definições", - "Metadata" : "Metadados" + "Metadata" : "Metadados", + "Bar" : "Barra" }, "nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); diff --git a/l10n/pt_PT.json b/l10n/pt_PT.json index 34df7bc90..cb8337a57 100644 --- a/l10n/pt_PT.json +++ b/l10n/pt_PT.json @@ -50,6 +50,7 @@ "Not grouped" : "Não agrupados", "Default" : "Predefinido", "Failed to save settings" : "Erro ao gravar as definições", - "Metadata" : "Metadados" + "Metadata" : "Metadados", + "Bar" : "Barra" },"pluralForm" :"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" } \ No newline at end of file diff --git a/lib/Service/GeophotoService.php b/lib/Service/GeophotoService.php index 10207cfe6..1d88d9062 100644 --- a/lib/Service/GeophotoService.php +++ b/lib/Service/GeophotoService.php @@ -28,6 +28,7 @@ use OCP\ICacheFactory; use OCP\IL10N; use OCP\IPreview; +use Psr\Log\LoggerInterface; class GeophotoService { @@ -45,6 +46,7 @@ class GeophotoService { private \OCP\ICache $backgroundJobCache; public function __construct( + private LoggerInterface $logger, IRootFolder $root, IL10N $l10n, GeophotoMapper $photoMapper, @@ -72,11 +74,16 @@ public function __construct( * @return bool */ public function clearCache(string $userId = ''): bool { - $a = $this->photosCache->clear($userId); - $b = $this->timeOrderedPointSetsCache->clear($userId); - $c = $this->backgroundJobCache->clear('recentlyAdded:'.$userId); - $d = $this->backgroundJobCache->clear('recentlyUpdated:'.$userId); - return $a and $b and $c and $d; + try { + $this->photosCache->clear($userId); + $this->timeOrderedPointSetsCache->clear($userId); + $this->backgroundJobCache->clear('recentlyAdded:'.$userId); + $this->backgroundJobCache->clear('recentlyUpdated:'.$userId); + return true; + + } catch (\Exception $e) { + return false; + } } /** @@ -106,56 +113,53 @@ public function getAll(string $userId, $folder = null, bool $respectNomediaAndNo $photoEntities = $this->photoMapper->findAll($userId); $filesById = []; - $cache = $folder->getStorage()->getCache(); $previewEnableMimetypes = $this->getPreviewEnabledMimetypes(); foreach ($photoEntities as $photoEntity) { - $cacheEntry = $cache->get($photoEntity->getFileId()); - if ($cacheEntry) { - // this path is relative to owner's storage - //$path = $cacheEntry->getPath(); - //but we want it relative to current user's storage - $files = $folder->getById($photoEntity->getFileId()); - if (empty($files)) { - continue; - } - $file = array_shift($files); - if ($file === null) { - continue; - } - $path = $userFolder->getRelativePath($file->getPath()); - $isIgnored = false; - foreach ($ignoredPaths as $ignoredPath) { - if (str_starts_with($path, $ignoredPath)) { - $isIgnored = true; - break; - } + // this path is relative to owner's storage + //$path = $cacheEntry->getPath(); + //but we want it relative to current user's storage + $files = $folder->getById($photoEntity->getFileId()); + if (empty($files)) { + continue; + } + $file = array_shift($files); + + if ($file === null) { + continue; + } + $path = $userFolder->getRelativePath($file->getPath()); + $isIgnored = false; + foreach ($ignoredPaths as $ignoredPath) { + if (str_starts_with($path, $ignoredPath)) { + $isIgnored = true; + break; } - if (!$isIgnored) { - $isRoot = $file === $userFolder; + } + if (!$isIgnored) { + $isRoot = $file === $userFolder; - $file_object = new \stdClass(); - $file_object->fileId = $photoEntity->getFileId(); - $file_object->fileid = $file_object->fileId; - $file_object->lat = $photoEntity->getLat(); - $file_object->lng = $photoEntity->getLng(); - $file_object->dateTaken = $photoEntity->getDateTaken() ?? \time(); - $file_object->basename = $isRoot ? '' : $file->getName(); - $file_object->filename = $this->normalizePath($path); - $file_object->etag = $cacheEntry->getEtag(); - //Not working for NC21 as Viewer requires String representation of permissions - // $file_object->permissions = $file->getPermissions(); - $file_object->type = $file->getType(); - $file_object->mime = $file->getMimetype(); - $file_object->lastmod = $file->getMTime(); - $file_object->size = $file->getSize(); - $file_object->path = $path; - $file_object->isReadable = $file->isReadable(); - $file_object->isUpdateable = $file->isUpdateable(); - $file_object->isShareable = $file->isShareable(); - $file_object->isDeletable = $file->isDeletable(); - $file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes); - $filesById[] = $file_object; - } + $file_object = new \stdClass(); + $file_object->fileId = $photoEntity->getFileId(); + $file_object->fileid = $file_object->fileId; + $file_object->lat = $photoEntity->getLat(); + $file_object->lng = $photoEntity->getLng(); + $file_object->dateTaken = $photoEntity->getDateTaken() ?? \time(); + $file_object->basename = $isRoot ? '' : $file->getName(); + $file_object->filename = $this->normalizePath($path); + $file_object->etag = $file->getEtag(); + //Not working for NC21 as Viewer requires String representation of permissions + // $file_object->permissions = $file->getPermissions(); + $file_object->type = $file->getType(); + $file_object->mime = $file->getMimetype(); + $file_object->lastmod = $file->getMTime(); + $file_object->size = $file->getSize(); + $file_object->path = $path; + $file_object->isReadable = $file->isReadable(); + $file_object->isUpdateable = $file->isUpdateable(); + $file_object->isShareable = $file->isShareable(); + $file_object->isDeletable = $file->isDeletable(); + $file_object->hasPreview = in_array($file_object->mime, $previewEnableMimetypes); + $filesById[] = $file_object; } } $this->photosCache->set($key, $filesById, 60 * 60 * 24); @@ -199,65 +203,61 @@ public function getNonLocalized(string $userId, $folder = null, bool $respectNom $tz = new \DateTimeZone(\date_default_timezone_get()); } foreach ($photoEntities as $photoEntity) { - $cacheEntry = $cache->get($photoEntity->getFileId()); - if ($cacheEntry) { - // this path is relative to owner's storage - //$path = $cacheEntry->getPath(); - // but we want it relative to current user's storage - $files = $folder->getById($photoEntity->getFileId()); - if (empty($files)) { - continue; - } - $file = array_shift($files); - if ($file === null) { - continue; - } - $path = $userFolder->getRelativePath($file->getPath()); - $isIgnored = false; - foreach ($ignoredPaths as $ignoredPath) { - if (str_starts_with($path, $ignoredPath)) { - $isIgnored = true; - break; - } + // this path is relative to owner's storage + //$path = $cacheEntry->getPath(); + // but we want it relative to current user's storage + $files = $folder->getById($photoEntity->getFileId()); + if (empty($files)) { + continue; + } + $file = array_shift($files); + if ($file === null) { + continue; + } + $path = $userFolder->getRelativePath($file->getPath()); + $isIgnored = false; + foreach ($ignoredPaths as $ignoredPath) { + if (str_starts_with($path, $ignoredPath)) { + $isIgnored = true; + break; } - if (!$isIgnored) { - $isRoot = $file === $userFolder; + } + if (!$isIgnored) { + $isRoot = $file === $userFolder; - //Unfortunately Exif stores the local and not the UTC time. There is no way to get the timezone, therefore it has to be given by the user. - $date = $photoEntity->getDateTaken() ?? \time(); + //Unfortunately Exif stores the local and not the UTC time. There is no way to get the timezone, therefore it has to be given by the user. + $date = $photoEntity->getDateTaken() ?? \time(); - $dateWithTimezone = new \DateTime(gmdate('Y-m-d H:i:s', $date), $tz); - $locations = $this->getLocationGuesses($dateWithTimezone->getTimestamp()); - foreach ($locations as $key => $location) { - $file_object = new \stdClass(); - $file_object->fileId = $photoEntity->getFileId(); - $file_object->fileid = $file_object->fileId; - $file_object->path = $this->normalizePath($path); - $file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes); - $file_object->lat = $location[0]; - $file_object->lng = $location[1]; - $file_object->dateTaken = $date; - $file_object->basename = $isRoot ? '' : $file->getName(); - $file_object->filename = $this->normalizePath($path); - $file_object->etag = $cacheEntry->getEtag(); - //Not working for NC21 as Viewer requires String representation of permissions - // $file_object->permissions = $file->getPermissions(); - $file_object->type = $file->getType(); - $file_object->mime = $file->getMimetype(); - $file_object->lastmod = $file->getMTime(); - $file_object->size = $file->getSize(); - $file_object->path = $path; - $file_object->isReadable = $file->isReadable(); - $file_object->isUpdateable = $file->isUpdateable(); - $file_object->isShareable = $file->isShareable(); - $file_object->isDeletable = $file->isDeletable(); - $file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes); - $file_object->trackOrDeviceId = $key; - if (!array_key_exists($key, $suggestionsBySource)) { - $suggestionsBySource[$key] = []; - } - $suggestionsBySource[$key][] = $file_object; + $dateWithTimezone = new \DateTime(gmdate('Y-m-d H:i:s', $date), $tz); + $locations = $this->getLocationGuesses($dateWithTimezone->getTimestamp()); + foreach ($locations as $key => $location) { + $file_object = new \stdClass(); + $file_object->fileId = $photoEntity->getFileId(); + $file_object->fileid = $file_object->fileId; + $file_object->path = $this->normalizePath($path); + $file_object->mime = $file->getMimetype(); + $file_object->hasPreview = in_array($file_object->mime, $previewEnableMimetypes); + $file_object->lat = $location[0]; + $file_object->lng = $location[1]; + $file_object->dateTaken = $date; + $file_object->basename = $isRoot ? '' : $file->getName(); + $file_object->filename = $this->normalizePath($path); + $file_object->etag = $file->getEtag(); + //Not working for NC21 as Viewer requires String representation of permissions + // $file_object->permissions = $file->getPermissions(); + $file_object->type = $file->getType(); + $file_object->lastmod = $file->getMTime(); + $file_object->size = $file->getSize(); + $file_object->path = $path; + $file_object->isReadable = $file->isReadable(); + $file_object->isUpdateable = $file->isUpdateable(); + $file_object->isShareable = $file->isShareable(); + $file_object->isDeletable = $file->isDeletable(); + $file_object->trackOrDeviceId = $key; + if (!array_key_exists($key, $suggestionsBySource)) { + $suggestionsBySource[$key] = []; } + $suggestionsBySource[$key][] = $file_object; } } } @@ -357,6 +357,7 @@ private function loadTimeorderedPointSets(string $userId, $folder = null, bool $ */ private function getTracksFromGPX($content): array { $tracks = []; + libxml_use_internal_errors(false); $gpx = simplexml_load_string($content); foreach ($gpx->trk as $trk) { $tracks[] = $trk; diff --git a/translationfiles/templates/maps.pot b/translationfiles/templates/maps.pot index 173817d17..8204ee2cc 100644 --- a/translationfiles/templates/maps.pot +++ b/translationfiles/templates/maps.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Nextcloud 3.14159\n" "Report-Msgid-Bugs-To: translations\\@example.com\n" -"POT-Creation-Date: 2025-01-11 01:18+0000\n" +"POT-Creation-Date: 2025-01-20 01:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n"