Skip to content

Commit b7e4640

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/nextcloud/sharing-0.2.4
2 parents 0ea6aa7 + 2a1a1ea commit b7e4640

File tree

7 files changed

+124
-114
lines changed

7 files changed

+124
-114
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## 1.6.0 - 2024.12.31 Scan photos of specific directory
7+
## 1.6.0 - [unreleased]
8+
### Added
89
- Scan photos of specific directory [#1231](https://github.com/nextcloud/maps/pull/1231) @tetebueno
10+
11+
### Fixed
12+
- Georeferenced photos from external folders not shown on map
13+
[#1371](https://github.com/nextcloud/maps/issues/1371) @umgfoin
14+
- Fix wrong failure-msg. when clearing photo-cache
15+
[#1375](https://github.com/nextcloud/maps/pull/1375) @umgfoin
916

1017

1118
## 1.5.0 - 2024.11.16 Nextcloud Hub 9

l10n/lt_LT.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ OC.L10N.register(
2323
"Category name" : "Kategorijos pavadinimas",
2424
"Rename" : "Pervadinti",
2525
"Add a favorite" : "Pridėti mėgstamą",
26-
"Delete share link" : "Ištrinti bendrinimo nuorodą",
26+
"Delete share link" : "Ištrinti viešinio nuorodą",
2727
"Copied!" : "Nukopijuota!",
28-
"Copy share link" : "Kopijuoti bendrinimo nuorodą",
28+
"Copy share link" : "Kopijuoti viešinio nuorodą",
2929
"Cancel" : "Atsisakyti",
3030
"Link copied" : "Nuoroda nukopijuota",
3131
"Link could not be copied to clipboard." : "Nepavyko nukopijuoti nuorodos į iškarpinę.",

l10n/lt_LT.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"Category name" : "Kategorijos pavadinimas",
2222
"Rename" : "Pervadinti",
2323
"Add a favorite" : "Pridėti mėgstamą",
24-
"Delete share link" : "Ištrinti bendrinimo nuorodą",
24+
"Delete share link" : "Ištrinti viešinio nuorodą",
2525
"Copied!" : "Nukopijuota!",
26-
"Copy share link" : "Kopijuoti bendrinimo nuorodą",
26+
"Copy share link" : "Kopijuoti viešinio nuorodą",
2727
"Cancel" : "Atsisakyti",
2828
"Link copied" : "Nuoroda nukopijuota",
2929
"Link could not be copied to clipboard." : "Nepavyko nukopijuoti nuorodos į iškarpinę.",

l10n/pt_PT.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ OC.L10N.register(
5252
"Not grouped" : "Não agrupados",
5353
"Default" : "Predefinido",
5454
"Failed to save settings" : "Erro ao gravar as definições",
55-
"Metadata" : "Metadados"
55+
"Metadata" : "Metadados",
56+
"Bar" : "Barra"
5657
},
5758
"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;");

l10n/pt_PT.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"Not grouped" : "Não agrupados",
5151
"Default" : "Predefinido",
5252
"Failed to save settings" : "Erro ao gravar as definições",
53-
"Metadata" : "Metadados"
53+
"Metadata" : "Metadados",
54+
"Bar" : "Barra"
5455
},"pluralForm" :"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"
5556
}

lib/Service/GeophotoService.php

Lines changed: 107 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use OCP\ICacheFactory;
2929
use OCP\IL10N;
3030
use OCP\IPreview;
31+
use Psr\Log\LoggerInterface;
3132

3233
class GeophotoService {
3334

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

4748
public function __construct(
49+
private LoggerInterface $logger,
4850
IRootFolder $root,
4951
IL10N $l10n,
5052
GeophotoMapper $photoMapper,
@@ -72,11 +74,16 @@ public function __construct(
7274
* @return bool
7375
*/
7476
public function clearCache(string $userId = ''): bool {
75-
$a = $this->photosCache->clear($userId);
76-
$b = $this->timeOrderedPointSetsCache->clear($userId);
77-
$c = $this->backgroundJobCache->clear('recentlyAdded:'.$userId);
78-
$d = $this->backgroundJobCache->clear('recentlyUpdated:'.$userId);
79-
return $a and $b and $c and $d;
77+
try {
78+
$this->photosCache->clear($userId);
79+
$this->timeOrderedPointSetsCache->clear($userId);
80+
$this->backgroundJobCache->clear('recentlyAdded:'.$userId);
81+
$this->backgroundJobCache->clear('recentlyUpdated:'.$userId);
82+
return true;
83+
84+
} catch (\Exception $e) {
85+
return false;
86+
}
8087
}
8188

8289
/**
@@ -106,56 +113,53 @@ public function getAll(string $userId, $folder = null, bool $respectNomediaAndNo
106113
$photoEntities = $this->photoMapper->findAll($userId);
107114

108115
$filesById = [];
109-
$cache = $folder->getStorage()->getCache();
110116
$previewEnableMimetypes = $this->getPreviewEnabledMimetypes();
111117
foreach ($photoEntities as $photoEntity) {
112-
$cacheEntry = $cache->get($photoEntity->getFileId());
113-
if ($cacheEntry) {
114-
// this path is relative to owner's storage
115-
//$path = $cacheEntry->getPath();
116-
//but we want it relative to current user's storage
117-
$files = $folder->getById($photoEntity->getFileId());
118-
if (empty($files)) {
119-
continue;
120-
}
121-
$file = array_shift($files);
122-
if ($file === null) {
123-
continue;
124-
}
125-
$path = $userFolder->getRelativePath($file->getPath());
126-
$isIgnored = false;
127-
foreach ($ignoredPaths as $ignoredPath) {
128-
if (str_starts_with($path, $ignoredPath)) {
129-
$isIgnored = true;
130-
break;
131-
}
118+
// this path is relative to owner's storage
119+
//$path = $cacheEntry->getPath();
120+
//but we want it relative to current user's storage
121+
$files = $folder->getById($photoEntity->getFileId());
122+
if (empty($files)) {
123+
continue;
124+
}
125+
$file = array_shift($files);
126+
127+
if ($file === null) {
128+
continue;
129+
}
130+
$path = $userFolder->getRelativePath($file->getPath());
131+
$isIgnored = false;
132+
foreach ($ignoredPaths as $ignoredPath) {
133+
if (str_starts_with($path, $ignoredPath)) {
134+
$isIgnored = true;
135+
break;
132136
}
133-
if (!$isIgnored) {
134-
$isRoot = $file === $userFolder;
137+
}
138+
if (!$isIgnored) {
139+
$isRoot = $file === $userFolder;
135140

136-
$file_object = new \stdClass();
137-
$file_object->fileId = $photoEntity->getFileId();
138-
$file_object->fileid = $file_object->fileId;
139-
$file_object->lat = $photoEntity->getLat();
140-
$file_object->lng = $photoEntity->getLng();
141-
$file_object->dateTaken = $photoEntity->getDateTaken() ?? \time();
142-
$file_object->basename = $isRoot ? '' : $file->getName();
143-
$file_object->filename = $this->normalizePath($path);
144-
$file_object->etag = $cacheEntry->getEtag();
145-
//Not working for NC21 as Viewer requires String representation of permissions
146-
// $file_object->permissions = $file->getPermissions();
147-
$file_object->type = $file->getType();
148-
$file_object->mime = $file->getMimetype();
149-
$file_object->lastmod = $file->getMTime();
150-
$file_object->size = $file->getSize();
151-
$file_object->path = $path;
152-
$file_object->isReadable = $file->isReadable();
153-
$file_object->isUpdateable = $file->isUpdateable();
154-
$file_object->isShareable = $file->isShareable();
155-
$file_object->isDeletable = $file->isDeletable();
156-
$file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes);
157-
$filesById[] = $file_object;
158-
}
141+
$file_object = new \stdClass();
142+
$file_object->fileId = $photoEntity->getFileId();
143+
$file_object->fileid = $file_object->fileId;
144+
$file_object->lat = $photoEntity->getLat();
145+
$file_object->lng = $photoEntity->getLng();
146+
$file_object->dateTaken = $photoEntity->getDateTaken() ?? \time();
147+
$file_object->basename = $isRoot ? '' : $file->getName();
148+
$file_object->filename = $this->normalizePath($path);
149+
$file_object->etag = $file->getEtag();
150+
//Not working for NC21 as Viewer requires String representation of permissions
151+
// $file_object->permissions = $file->getPermissions();
152+
$file_object->type = $file->getType();
153+
$file_object->mime = $file->getMimetype();
154+
$file_object->lastmod = $file->getMTime();
155+
$file_object->size = $file->getSize();
156+
$file_object->path = $path;
157+
$file_object->isReadable = $file->isReadable();
158+
$file_object->isUpdateable = $file->isUpdateable();
159+
$file_object->isShareable = $file->isShareable();
160+
$file_object->isDeletable = $file->isDeletable();
161+
$file_object->hasPreview = in_array($file_object->mime, $previewEnableMimetypes);
162+
$filesById[] = $file_object;
159163
}
160164
}
161165
$this->photosCache->set($key, $filesById, 60 * 60 * 24);
@@ -199,65 +203,61 @@ public function getNonLocalized(string $userId, $folder = null, bool $respectNom
199203
$tz = new \DateTimeZone(\date_default_timezone_get());
200204
}
201205
foreach ($photoEntities as $photoEntity) {
202-
$cacheEntry = $cache->get($photoEntity->getFileId());
203-
if ($cacheEntry) {
204-
// this path is relative to owner's storage
205-
//$path = $cacheEntry->getPath();
206-
// but we want it relative to current user's storage
207-
$files = $folder->getById($photoEntity->getFileId());
208-
if (empty($files)) {
209-
continue;
210-
}
211-
$file = array_shift($files);
212-
if ($file === null) {
213-
continue;
214-
}
215-
$path = $userFolder->getRelativePath($file->getPath());
216-
$isIgnored = false;
217-
foreach ($ignoredPaths as $ignoredPath) {
218-
if (str_starts_with($path, $ignoredPath)) {
219-
$isIgnored = true;
220-
break;
221-
}
206+
// this path is relative to owner's storage
207+
//$path = $cacheEntry->getPath();
208+
// but we want it relative to current user's storage
209+
$files = $folder->getById($photoEntity->getFileId());
210+
if (empty($files)) {
211+
continue;
212+
}
213+
$file = array_shift($files);
214+
if ($file === null) {
215+
continue;
216+
}
217+
$path = $userFolder->getRelativePath($file->getPath());
218+
$isIgnored = false;
219+
foreach ($ignoredPaths as $ignoredPath) {
220+
if (str_starts_with($path, $ignoredPath)) {
221+
$isIgnored = true;
222+
break;
222223
}
223-
if (!$isIgnored) {
224-
$isRoot = $file === $userFolder;
224+
}
225+
if (!$isIgnored) {
226+
$isRoot = $file === $userFolder;
225227

226-
//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.
227-
$date = $photoEntity->getDateTaken() ?? \time();
228+
//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.
229+
$date = $photoEntity->getDateTaken() ?? \time();
228230

229-
$dateWithTimezone = new \DateTime(gmdate('Y-m-d H:i:s', $date), $tz);
230-
$locations = $this->getLocationGuesses($dateWithTimezone->getTimestamp());
231-
foreach ($locations as $key => $location) {
232-
$file_object = new \stdClass();
233-
$file_object->fileId = $photoEntity->getFileId();
234-
$file_object->fileid = $file_object->fileId;
235-
$file_object->path = $this->normalizePath($path);
236-
$file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes);
237-
$file_object->lat = $location[0];
238-
$file_object->lng = $location[1];
239-
$file_object->dateTaken = $date;
240-
$file_object->basename = $isRoot ? '' : $file->getName();
241-
$file_object->filename = $this->normalizePath($path);
242-
$file_object->etag = $cacheEntry->getEtag();
243-
//Not working for NC21 as Viewer requires String representation of permissions
244-
// $file_object->permissions = $file->getPermissions();
245-
$file_object->type = $file->getType();
246-
$file_object->mime = $file->getMimetype();
247-
$file_object->lastmod = $file->getMTime();
248-
$file_object->size = $file->getSize();
249-
$file_object->path = $path;
250-
$file_object->isReadable = $file->isReadable();
251-
$file_object->isUpdateable = $file->isUpdateable();
252-
$file_object->isShareable = $file->isShareable();
253-
$file_object->isDeletable = $file->isDeletable();
254-
$file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes);
255-
$file_object->trackOrDeviceId = $key;
256-
if (!array_key_exists($key, $suggestionsBySource)) {
257-
$suggestionsBySource[$key] = [];
258-
}
259-
$suggestionsBySource[$key][] = $file_object;
231+
$dateWithTimezone = new \DateTime(gmdate('Y-m-d H:i:s', $date), $tz);
232+
$locations = $this->getLocationGuesses($dateWithTimezone->getTimestamp());
233+
foreach ($locations as $key => $location) {
234+
$file_object = new \stdClass();
235+
$file_object->fileId = $photoEntity->getFileId();
236+
$file_object->fileid = $file_object->fileId;
237+
$file_object->path = $this->normalizePath($path);
238+
$file_object->mime = $file->getMimetype();
239+
$file_object->hasPreview = in_array($file_object->mime, $previewEnableMimetypes);
240+
$file_object->lat = $location[0];
241+
$file_object->lng = $location[1];
242+
$file_object->dateTaken = $date;
243+
$file_object->basename = $isRoot ? '' : $file->getName();
244+
$file_object->filename = $this->normalizePath($path);
245+
$file_object->etag = $file->getEtag();
246+
//Not working for NC21 as Viewer requires String representation of permissions
247+
// $file_object->permissions = $file->getPermissions();
248+
$file_object->type = $file->getType();
249+
$file_object->lastmod = $file->getMTime();
250+
$file_object->size = $file->getSize();
251+
$file_object->path = $path;
252+
$file_object->isReadable = $file->isReadable();
253+
$file_object->isUpdateable = $file->isUpdateable();
254+
$file_object->isShareable = $file->isShareable();
255+
$file_object->isDeletable = $file->isDeletable();
256+
$file_object->trackOrDeviceId = $key;
257+
if (!array_key_exists($key, $suggestionsBySource)) {
258+
$suggestionsBySource[$key] = [];
260259
}
260+
$suggestionsBySource[$key][] = $file_object;
261261
}
262262
}
263263
}
@@ -357,6 +357,7 @@ private function loadTimeorderedPointSets(string $userId, $folder = null, bool $
357357
*/
358358
private function getTracksFromGPX($content): array {
359359
$tracks = [];
360+
libxml_use_internal_errors(false);
360361
$gpx = simplexml_load_string($content);
361362
foreach ($gpx->trk as $trk) {
362363
$tracks[] = $trk;

translationfiles/templates/maps.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Nextcloud 3.14159\n"
1010
"Report-Msgid-Bugs-To: translations\\@example.com\n"
11-
"POT-Creation-Date: 2025-01-11 01:18+0000\n"
11+
"POT-Creation-Date: 2025-01-20 01:17+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"

0 commit comments

Comments
 (0)