nextcloud / photos

📸 Your memories under your control
GNU Affero General Public License v3.0
516 stars 59 forks source link

Cannot add photo to album #1558

Open p5n opened 1 year ago

p5n commented 1 year ago

To Reproduce

Expected behavior Added photo

Desktop (please complete the following information):

Was able to fix it by adding following function to https://github.com/nextcloud/photos/blob/master/lib/Sabre/Album/AlbumRoot.php

$ diff AlbumRoot.php.bak AlbumRoot.php 
84a85,88
>   public function getPath() {
>       return $this->rootFolder->getUserFolder($this->userId)->getPath();
>   }
> 

Not sure if it is correct solution but photo was added somehow.

simonspa commented 1 year ago

I somehow cannot reproduce this with master from both NC and Photos.

p5n commented 1 year ago

With nextcloud 25.0.3 it adds without this patch, but error appeared in top right corner that it failed to add photo. Also it looks like adding photo from shared read-only folder affects. Own photo was added without error.

siccovansas commented 1 year ago

I indeed cannot add a photo to an album if the photo is shared with me. I also get the 'Failed to add...' message in the top right corner.

chmeeedalf commented 1 year ago

I indeed cannot add a photo to an album if the photo is shared with me. I also get the 'Failed to add...' message in the top right corner.

I see the same thing, and it's even more amusing because it happens when I upload a photo to a directory shared with me, and then try to add that photo to an album. I don't see any errors in the logs, just a failed message in the corner.

joshtrichards commented 12 months ago

Can anyone experiencing this provide the log entry (i.e. the full stack trace) from their nextcloud.log? That will help in getting this issue looked at more closely.

siccovansas commented 12 months ago

Here are my entries from nextcloud.log when trying to add a photo from a shared folder:

{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Maps\\Hooks\\FileHooks::$lockingProvider is deprecated at /var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php#46","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"webdav","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Can't add file to album, only files from XXXXUSER can be added","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","exception":{"Exception":"Sabre\\DAV\\Exception\\Forbidden","Message":"Can't add file to album, only files from XXXXUSER can be added","Code":0,"Trace":[{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php","line":132,"function":"copyInto","class":"OCA\\Photos\\Sabre\\Album\\AlbumRoot","type":"->","args":["XXXXFILE.JPG","files/XXXXUSER/XXXXPATH/XXXXFILE.JPG",["OCA\\DAV\\Connector\\Sabre\\File"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":659,"function":"copy","class":"Sabre\\DAV\\Tree","type":"->","args":["files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","photos/XXXXUSER/albums/XXXSHAREDALBUM/XXXXFILE.JPG"]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpCopy","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:COPY",[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":366,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":172,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php","Line":167,"message":"Can't add file to album, only files from XXXXUSER can be added","exception":{},"CustomMessage":"Can't add file to album, only files from XXXXUSER can be added"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Maps\\Hooks\\FileHooks::$lockingProvider is deprecated at /var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php#46","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}

Line 6 seems to hold a clue: Can't add file to album, only files from XXXXUSER can be added :) (Note: XXXXUSER is a substitute for my username; so it says that I can only add my own files to the album).

As a user I would expect all photos that I can select from the 'Add photos to this album' popup picker to be addable to the album. Given that shared photos are shown in the picker I should be able to add them to the album.

ubrfkr commented 6 months ago

I still have this issue. Pictures from shared folders can't be added to shared albums. Is there any progress on this? Or does anyone know a workaround?

titilambert commented 5 months ago

The error/issue is there: https://github.com/nextcloud/photos/blob/4c7c00ea3f5686c3b2d6158d6b23cfb3f7fe6de8/lib/Sabre/Album/AlbumRoot.php#L167 But I guess there is a reason why we can not do it ...

StefanAbl commented 5 months ago

But I guess there is a reason why we can not do it ...

This behavior makes sense in many cases, however there are other use cases in which adding a picture to an album should be possible even though the picture was shared with the user adding it. For example Alice shares a folder and an Album with Bob, Bob should then be allowed to add Alice's pictures to Alice's album.

HolgerDoerrschuck commented 4 months ago

Hi all, I have two user on my nexcloud 1=boss 2=employee. All pictures are uploaded by boss and the folder is shared with employee. Boss creates now an album and shared this with employee.

Employee can display this album and can remove pictures but he can not add pictures even if they are uploaded by himselfe. For me this is a cleare bug and stops me to use nextcloud with multiple users.

So please - can someone provide a fix for that? I also tried the app groupfolder but this is not really working with memories

nderambure commented 4 months ago

Same problem here, on 15 differents nextclouds. If the photo added into an album does not belong to the user, it fails with message "Can't add file to album, only files from...". Very disturbing since the user can see all images shared with him...

sbrems commented 3 months ago

I also have the same issue. To me this is also clearly a bug and really limits my usability of nextcloud. Maybe it comes from the issue what to do with the album, if sharing is ended. But to me it should maybe just be a show list of files not accessible anymore, once the permission is revoked.

pixelpunk-DE commented 2 months ago

I have the same issue. Only the owner sharing the folder can add photos to albums. No matter who uploaded the photos or created the album. But everyone the album is shared with can delete photos from it.

I also tried to create a group as admin and share a folder with this group. No one in the group can use photos from this folder then. Transferring the ownership of a folder does not help either.

I would expect the same behavior when the share is revoked as if they were deleted: placeholder thumbs.

Steps to reproduce:

Or Bob can create an album an add Anna as collaborator, same result.