payload
payload copied to clipboard
Fix: avoid deleting associated files on update for versioned collection docs
Description
Currently it is not possible to restore any other version of a document with files (collectionConfig.uploads=true
) as those files get always deleted on update.
For a versioned collection the files should be kept until the related version is deleted or the entire document is deleted. Otherwise it is not possible to restore an older file version.
This is includes also the package plugin-cloud-storage
.
The fix
I added in the operations for update
and updateById
a check if the collection is versioned and avoid running the deleteAssociatedFiles
method if so.
For the package plugin-cloud-storage
I added the check in the beforeChange
handler which will avoid deleting files if the collection is versioned.
The files are still correctly deleted once the whole document is deleted.
- [x] I have read and understand the CONTRIBUTING.md document in this repository.
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
Checklist:
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] Existing test suite passes locally with my changes
- [ ] I have made corresponding changes to the documentation