Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/nextcloud/moment-1…
Browse files Browse the repository at this point in the history
….3.2
  • Loading branch information
tacruc authored Jan 20, 2025
2 parents 21542f2 + 2a1a1ea commit 0013401
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 114 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions l10n/lt_LT.js
Original file line number Diff line number Diff line change
Expand Up @@ -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ę.",
Expand Down
4 changes: 2 additions & 2 deletions l10n/lt_LT.json
Original file line number Diff line number Diff line change
Expand Up @@ -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ę.",
Expand Down
3 changes: 2 additions & 1 deletion l10n/pt_PT.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
3 changes: 2 additions & 1 deletion l10n/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
}
213 changes: 107 additions & 106 deletions lib/Service/GeophotoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCP\ICacheFactory;
use OCP\IL10N;
use OCP\IPreview;
use Psr\Log\LoggerInterface;

class GeophotoService {

Expand All @@ -45,6 +46,7 @@ class GeophotoService {
private \OCP\ICache $backgroundJobCache;

public function __construct(
private LoggerInterface $logger,
IRootFolder $root,
IL10N $l10n,
GeophotoMapper $photoMapper,
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion translationfiles/templates/maps.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down

0 comments on commit 0013401

Please sign in to comment.