Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-08-02 17:19:05 +0300
committerLouis Chemineau <louis@chmn.me>2022-08-22 21:03:52 +0300
commit62dbf99ec049a24061fe9238461eccd2cf67d609 (patch)
treeef57dd2af89319e9f1541ae236a0e5b8225aeab8 /lib
parent3cd7fede24e383072afbceb92be41125f2ebaa4b (diff)
use unique filenames in albums
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'lib')
-rw-r--r--lib/Album/AlbumWithFiles.php2
-rw-r--r--lib/Sabre/Album/AlbumPhoto.php6
-rw-r--r--lib/Sabre/Album/AlbumRoot.php2
-rw-r--r--lib/Sabre/Album/PropFindPlugin.php50
4 files changed, 56 insertions, 4 deletions
diff --git a/lib/Album/AlbumWithFiles.php b/lib/Album/AlbumWithFiles.php
index d4724091..cc6d0d1a 100644
--- a/lib/Album/AlbumWithFiles.php
+++ b/lib/Album/AlbumWithFiles.php
@@ -23,8 +23,6 @@ declare(strict_types=1);
namespace OCA\Photos\Album;
-use OC\Files\Cache\CacheEntry;
-
class AlbumWithFiles {
private AlbumInfo $info;
/** @var AlbumFile[] */
diff --git a/lib/Sabre/Album/AlbumPhoto.php b/lib/Sabre/Album/AlbumPhoto.php
index 88985139..5bd31830 100644
--- a/lib/Sabre/Album/AlbumPhoto.php
+++ b/lib/Sabre/Album/AlbumPhoto.php
@@ -51,7 +51,7 @@ class AlbumPhoto implements IFile {
}
public function getName() {
- return $this->file->getName();
+ return $this->file->getFileId() . "-" . $this->file->getName();
}
public function setName($name) {
@@ -92,4 +92,8 @@ class AlbumPhoto implements IFile {
public function getSize() {
return $this->file->getSize();
}
+
+ public function getFile(): AlbumFile {
+ return $this->file;
+ }
}
diff --git a/lib/Sabre/Album/AlbumRoot.php b/lib/Sabre/Album/AlbumRoot.php
index 222fa53c..4a51d619 100644
--- a/lib/Sabre/Album/AlbumRoot.php
+++ b/lib/Sabre/Album/AlbumRoot.php
@@ -80,7 +80,7 @@ class AlbumRoot implements ICollection, ICopyTarget {
public function getChild($name): AlbumPhoto {
foreach ($this->album->getFiles() as $file) {
- if ($file->getName() === $name) {
+ if ($file->getFileId() . "-" . $file->getName() === $name) {
return new AlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->userFolder);
}
}
diff --git a/lib/Sabre/Album/PropFindPlugin.php b/lib/Sabre/Album/PropFindPlugin.php
new file mode 100644
index 00000000..02b62096
--- /dev/null
+++ b/lib/Sabre/Album/PropFindPlugin.php
@@ -0,0 +1,50 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Photos\Sabre\Album;
+
+use Sabre\DAV\INode;
+use Sabre\DAV\PropFind;
+use Sabre\DAV\Server;
+use Sabre\DAV\ServerPlugin;
+
+class PropFindPlugin extends ServerPlugin {
+ private Server $server;
+
+ public function initialize(Server $server) {
+ $this->server = $server;
+
+ $this->server->on('propFind', [$this, 'propFind']);
+ }
+
+
+ public function propFind(PropFind $propFind, INode $node) {
+ if (!($node instanceof AlbumPhoto)) {
+ return;
+ }
+
+ $propFind->handle('{http://nextcloud.org/ns}file-name', function () use ($node) {
+ return $node->getFile()->getName();
+ });
+ }
+}