nextcloud / collectives

Collectives is a Nextcloud App for activist and community projects to organize together.
GNU Affero General Public License v3.0
101 stars 19 forks source link

Links to files break after moving or renaming files #1527

Open TheNomad11 opened 1 month ago

TheNomad11 commented 1 month ago

Describe the bug Links to files break after moving or renaming files

To Reproduce Steps to reproduce the behavior:

  1. Make a link from a Collectives page to a pdf file in Files
  2. Click on the link
  3. The pdf loads correctly
  4. Go to Files and move the pdf file
  5. Go back to Collectives, reload, and click on the link to the pdf file
  6. The pdf file does not load, a message appears "File no loger exists"
  7. Copy the link and put in the Browser URL bar
  8. The pdf loads

Expected behavior The Pdf link loads, as these links are permanant within Nextcloud. They still work after moving and renaming

Server details:

Client details:

mejo- commented 3 weeks ago

Hey @TheNomad11, thanks for your report. I'm able to reproduce your bug.

It seems like the server returns an outdated reference object from the cache. We probably need to take care that the the reference cache for files gets invalidated when they get moved or copied.

Cc @juliusknorr as you worked on this in the past.

juliusknorr commented 2 weeks ago

Which URL format is being used? Wondering with the internal URL we should not see any change in the URL with the move and I'd expect that with any other we should still have the file id as identifier, so maybe that is rather a but in the extraction logic to get the file metadata for the specific link

mejo- commented 2 weeks ago

Which URL format is being used? Wondering with the internal URL we should not see any change in the URL with the move and I'd expect that with any other we should still have the file id as identifier, so maybe that is rather a but in the extraction logic to get the file metadata for the specific link

Exactly, the URL does not change. But the reference response contains the file metadata which contains the file name (which changed) - and apparently this is passed to the viewer for opening the file.

juliusknorr commented 2 weeks ago

All right, in that case it should be just a matter if invalidating the cache in https://github.com/nextcloud/server/blob/dae7c159f728a90ffa53247d6e033abdae5d2bd6/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php#L30