Reuse existing files as previews, icons or featured images #161

Merged
Anna Sirota merged 11 commits from files-allow-reuse-between-ext into main 2024-06-04 12:23:26 +02:00
Owner

Currently duplicate uploads cause a validation error, which is very annoying in both Draft and Edit flow.

A better way to handle duplicates would be to just reuse existing records of files matching them by the hash.

It will be possible to:

  • upload the same image as a preview or featured image on different extensions;
  • upload the same image as an icon on different extensions;
  • select the same video/image multiple times (by mistake?) while adding previews on Draft or Edit page: first one will be saved, the rest of the duplicates will be ignored.

If all extensions referencing the file in any way are deleted, the file remains in the database: no thumbnail generating or scanning will happen if/when the file gets re-uploaded as a preview or featured image.
We could choose to implement some kind of clean up later, if this becomes a problem.

In all cases of re-upload File.user will not change: this shouldn't be a problem because currently there's no code relying on image ownership.

Version files will remain the only exception from this changed behaviour: it will only be possible to re-upload a version file once the version itself is deleted (which also deletes its file).

As a consequence of this change File.extension_id is dropped, because it is no longer possible to choose which extension should be saved there.

Should take care of #157

Currently duplicate uploads cause a validation error, which is very annoying in both Draft and Edit flow. A better way to handle duplicates would be to just reuse existing records of files matching them by the hash. It will be possible to: * upload the same image as a preview or featured image on different extensions; * upload the same image as an icon on different extensions; * select the same video/image multiple times (by mistake?) while adding previews on Draft or Edit page: first one will be saved, the rest of the duplicates will be ignored. If all extensions referencing the file in any way are deleted, the file remains in the database: no thumbnail generating or scanning will happen if/when the file gets re-uploaded as a preview or featured image. We could choose to implement some kind of clean up later, if this becomes a problem. In all cases of re-upload `File.user` will not change: this shouldn't be a problem because currently there's no code relying on image ownership. Version files will remain the only exception from this changed behaviour: it will only be possible to re-upload a version file once the version itself is deleted (which also deletes its file). As a consequence of this change `File.extension_id` is dropped, because it is no longer possible to choose which extension should be saved there. Should take care of https://projects.blender.org/infrastructure/extensions-website/issues/157
Anna Sirota added 5 commits 2024-06-03 19:39:33 +02:00
Anna Sirota added 1 commit 2024-06-03 20:00:58 +02:00
Anna Sirota changed title from WIP: Reuse existing files as previews, icons or featured images to Reuse existing files as previews, icons or featured images 2024-06-03 20:07:09 +02:00
Anna Sirota added 3 commits 2024-06-04 11:04:08 +02:00
Anna Sirota added 2 commits 2024-06-04 11:12:41 +02:00
Oleg-Komarov approved these changes 2024-06-04 12:08:08 +02:00
Anna Sirota merged commit b0bb4905b2 into main 2024-06-04 12:23:26 +02:00
Anna Sirota deleted branch files-allow-reuse-between-ext 2024-06-04 12:23:27 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/extensions-website#161
No description provided.