Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content lost after file renaming from .md to .txt #5736

Open
cybermyber opened this issue Apr 30, 2024 · 3 comments
Open

Content lost after file renaming from .md to .txt #5736

cybermyber opened this issue Apr 30, 2024 · 3 comments
Labels
1. to develop bug Something isn't working high

Comments

@cybermyber
Copy link

Describe the bug
If you rename an .md file to a .txt file, the content will be lost after opening it in the built-in text editor.
If you download the renamed file before opening it in the built-in text editor, the content is retained.

To Reproduce
Steps to reproduce the behavior:

  1. Create or upload a new .md-File with some content
  2. Open the file with the text editor and check the content
  3. Close the file and rename it to example_filename.txt
  4. Open the example_filename.txt-File with the text editor

Expected behavior
After renaming from .md to .txt, the former content should be retained after opening with the text editor.

Screenshots
Screenshot from 2024-04-30 13-40-26
Screenshot from 2024-04-30 13-40-50

Server details:

  • Nextcloud version: 28.0.2
  • PHP Version: 8.1
  • Database: MariaDB 10.5.23

Client details:

  • OS: Fedora 39
  • Browser: Chrome
  • Browser version: 123.0.6312.122
  • Device: Desktop
@cybermyber cybermyber added the bug Something isn't working label Apr 30, 2024
@mejo-
Copy link
Member

mejo- commented May 14, 2024

I was able to reproduce this. Definitely something we should look into. @juliushaertl @max-nextcloud any idea what is happening here? I would have expected the markdown source to be displayed in the editor instead of all content being deleted 🤔

@mejo- mejo- added the high label May 14, 2024
@max-nextcloud
Copy link
Collaborator

I suspect the file id stays the same after the rename but the file is now opened with the plaintext editor rather than the markdown editor. At the same time it tries to recover the y.js state from the previous editing session which is invalid in the plaintext editor context.

Nice catch! We did not account for that yet.

@max-nextcloud
Copy link
Collaborator

I see two ways to fix this:

  1. Clear the document state and all related database entries when a rename changes the mime type between markdown and something else.
  2. add a mimetype or editor type to the key for finding the document state for a given document
  3. both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop bug Something isn't working high
Projects
Status: 📄 To do (~10 entries)
Development

No branches or pull requests

3 participants