spreed icon indicating copy to clipboard operation
spreed copied to clipboard

Renaming breaks file preview for internal links

Open bentuna opened this issue 10 months ago • 2 comments

Steps to reproduce

  1. Copy an internal link of a file (i.e. a PDF).
  2. Paste the link in a Talk message and send it.
  3. See how a preview of the file gets rendered below the link in the chat. When you click on the preview, the file opens.
  4. Rename the file in Nextcloud Files.
  5. Go back to the Talk chat and see how the file name in the preview is not updated and when you click on it, Talk shows an error "File does not exist anymore" and the file is not opened.

Expected behaviour

The file name in the preview gets updated on rename and the preview keeps working as a link to the file.

Actual behaviour

The file name in the preview is not updated and when you click on it, Talk shows an error "File does not exist anymore" and the file is not opened.

Talk app

Talk app version: 20.1.4

Custom Signaling server configured: yes, version 4e34e97f82dead32392b278c56229d47faecc728

Custom TURN server configured: yes

Custom STUN server configured: yes

Nextcloud version

30.0.6

bentuna avatar Feb 25 '25 23:02 bentuna

Reproducible. Although one thing I noticed:

  • My thought is that reference provider returns cached result: https://github.com/nextcloud/server/blob/86f3b81de7cc2d9db48d54120fae315d80ad3f75/core/Controller/ReferenceApiController.php#L110 from this response I see the correct internal link, but old filename
  • If you share internal link, then rename a file, then share a file itself -> preview will be updated accordingly (cache reset)

@juliusknorr I see from initial commit it is cached for 1 hour?

Antreesy avatar Feb 26 '25 09:02 Antreesy

Yes, in addition to the request caching in the browser there is also caching in the backend at https://github.com/nextcloud/server/blob/86f3b81de7cc2d9db48d54120fae315d80ad3f75/lib/private/Collaboration/Reference/ReferenceManager.php#L29 (also for 1 hour).

We have a way to invalidate at least the server side memory cache where we could also listen to a rename event https://github.com/nextcloud/server/blob/86f3b81de7cc2d9db48d54120fae315d80ad3f75/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php

juliusknorr avatar Mar 10 '25 11:03 juliusknorr