Deleting files should not delete from old manuscript versions
Current behaviour: If a new manuscript version is created, and then a file is deleted from that version (either an attachment or an image within the manuscript source), the same file will become unavailable to previous versions of the manuscript.
This is because currently, when creating a new version of a manuscript, files are duplicated by reference only. Deleting a file on one version then deletes the single file that all versions are referring to.
Proposed solution: when creating a new version, all files (both attachments and within manuscript source) should be recreated as new file objects (i.e., a new file stored in S3, and a new file record in the DB).
Update: Alexgeo recommended that instead of duplicating the file on S3, we instead just duplicate its representation in the DB:
Currently, the delete operation of the file controller provided by Coko server offers the option to just delete a file's db representation and leave the actual file intact on its bucket https://gitlab.coko.foundation/cokoapps/server/-/blob/master/src/models/file/file.controller.js#L55. By keeping the actual files you can just create new file db representations for each of your manuscript versions and all of theses to point to the original initial files on the bucket. Then for each manuscript version you will be free to delete files associated with that version without any impact on the rest of the versions.