Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Apr 23, 2025

This issue happens reproducible if:

  • Versions is disabled
  • Upload a file
  • Enable versions
  • Upload same file unchanged
  • Now the error happens.

Problem is that the mtime is unchanged so no version will be created on the upload, but it tries to update the last version which does not exists. Instead of "upload same file unchanged" you can also - like in the example stack trace above - use Android with an SD card with invalid mtime -> the mtime will be stripped so its always the same. Instead of disable versions the same also happens if e.g. the versions creation failed due to other issues.

The solution now is to catch the exception and create if not exists. A cleaner solution would be to have a method on the versions backend like hasVersionEntity(File $file, int $revision): bool but this would be a breaking change or at least a feature that apps need to implement.

This issue happens reproducible if:
- Versions is disabled
- Upload a file
- Enable versions
- Upload same file unchanged
- Now the error happens.

Problem is that the mtime is unchanged so no version will be created on the upload, but it tries to update the last version which does not exists.
Instead of "upload same file unchanged" you can also - like in the example stack trace above - use Android with an SD card with invalid mtime -> the mtime will be stripped so its always the same.
Instead of disable versions the same also happens if e.g. the versions creation failed due to other issues.

The solution now is to catch the exception and create if not exists.
A cleaner solution would be to have a method on the versions backend
like `hasVersionEntity(File $file, int $revision): bool` but this would
be a breaking change or at least a feature that apps need to implement.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux requested a review from artonge April 23, 2025 14:06
@susnux susnux requested a review from a team as a code owner April 23, 2025 14:06
@susnux susnux requested review from skjnldsv and yemkareems and removed request for a team April 23, 2025 14:06
@susnux susnux added this to the Nextcloud 32 milestone Apr 23, 2025
@susnux
Copy link
Contributor Author

susnux commented Apr 23, 2025

/backport to stable30

@susnux
Copy link
Contributor Author

susnux commented Apr 23, 2025

/backport to stable31

@susnux susnux merged commit 0051db7 into master Apr 24, 2025
228 of 238 checks passed
@susnux susnux deleted the fix/files-version-creation branch April 24, 2025 11:30
@skjnldsv skjnldsv mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants