Ghost/ghost
Simon Backx 8e66edee2b
🐛 Fixed storing original files for images (#16117)
fixes https://github.com/TryGhost/Team/issues/481

This change fixes an issue when multiple images with the same name are
uploaded in parallel. The current system does not guarantee that the
original filename is stored under NAME+`_o`, because the upload for the
original file and the resized file are happening in parallel.

Solution:
- Wait for the storage of the resized image (= the image without the _o
suffix) before storing the original file.
- When that is stored, use the generated file name of the stored image
to generate the filename with the _o suffix. This way, it will always
match and we don't risk both files to have a different number suffix.
We'll also set the `targetDir` argument when saving the file, to avoid
storing the original file in a different directory (when uploading a
file around midnight both files could be stored in 2023/01 and 2023/02).

Some extra optimisations needed with this fix:
- Previously when uploading image.jpg, while it already exists, it would
store two filenames on e.g., `image-3.jpg` and `image_o-3.jpg`. Note the
weird positioning of `_o`. This probably caused bugs when uploading
files named `image-3.jpg`, which would store the original in
`image-3_o.jpg`, but this original would never be used by the
handle-image-sizes middleware (it would look for `image_o-3.jpg`). This
fix would solve this weird naming issue, and make it more consistent.
But we need to make sure our middlewares (including handle-image-sizes)
will be able to handle both file locations to remain compatible with the
old format. This isn't additional work, because it would fix the old bug
too.
- Prevent uploading files that end with `_o`, e.g. by automatically
stripping that suffix from uploaded files. To prevent collisions.

Advantage(s):
- We keep the original file name, which is better for SEO.
- No changes required to the storage adapters.

Downside(s):
- The storage of both files will nog happen parallel any longer. But I
expect the performance implications to be minimal.
- Changes to the routing: normalize middleware is removed
2023-01-30 16:40:50 +01:00
..
adapter-manager Fixed configUtils and adapter cache issues in E2E tests (#16167) 2023-01-30 14:06:20 +01:00
admin Updated names 2023-01-30 15:16:01 +00:00
api-framework Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
api-version-compatibility-service Limited integrations triggering version mismatch emails 2023-01-30 17:57:14 +08:00
audience-feedback Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
bootstrap-socket Added version information to log lines 2023-01-20 13:18:44 +01:00
constants Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
core 🐛 Fixed storing original files for images (#16117) 2023-01-30 16:40:50 +01:00
custom-theme-settings-service Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
data-generator Added WebMentions to data generator 2023-01-23 17:39:00 +00:00
domain-events Added version information to log lines 2023-01-20 13:18:44 +01:00
dynamic-routing-events Added dynamic-routing-events package 2023-01-23 16:33:41 +08:00
email-analytics-provider-mailgun Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
email-analytics-service Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
email-content-generator Update dependency fs-extra to v11 2022-12-13 10:59:55 +07:00
email-events Added 100% test coverage for EmailEventStorage 2023-01-10 16:36:41 +01:00
email-service 🐛 Fixed HTML escaping of feature_image_caption in newsletters 2023-01-30 14:39:08 +01:00
email-suppression-list Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
express-dynamic-redirects Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
extract-api-key Fixed full Admin test suite running during unit tests 2022-08-15 15:34:52 +02:00
html-to-plaintext Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
i18n Update dependency i18next to v22.4.9 2023-01-19 17:58:16 +00:00
importer-revue Updated Koenig packages 2023-01-04 11:27:39 +01:00
job-manager Improved job manager test stability 2023-01-30 14:19:16 +01:00
link-redirects Update dependency @types/express to v4.17.16 2023-01-25 11:28:02 +01:00
link-replacer Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
link-tracking Lowered threshold for link-tracking coverage 2023-01-04 11:27:39 +01:00
magic-link Update dependency @types/nodemailer to v6.4.7 2023-01-03 18:46:57 +01:00
mailgun-client Improved handling large amounts of email events (#16189) 2023-01-26 16:06:15 +01:00
member-attribution Added outbound link tagging setting (#16146) 2023-01-20 13:41:36 +01:00
member-events Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
members-api Added version information to log lines 2023-01-20 13:18:44 +01:00
members-csv Update dependency fs-extra to v11 2022-12-13 10:59:55 +07:00
members-events-service Added version information to log lines 2023-01-20 13:18:44 +01:00
members-importer Added version information to log lines 2023-01-20 13:18:44 +01:00
members-ssr Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
minifier Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
mw-api-version-mismatch Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
mw-cache-control Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
mw-error-handler Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
mw-session-from-token Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
mw-update-user-last-seen Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
mw-vhost Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
oembed-service Update metascraper to v5.33.5 2023-01-23 12:04:33 +00:00
offers Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
package-json Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
payments Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
portal Updated email tips copy 2023-01-26 13:12:03 -04:00
referrers Added new urls to known referrers list for source attribution 2023-01-20 18:13:05 +05:30
security Updated @tryghost dependencies (#16005) 2022-12-14 11:18:55 +07:00
session-service Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
settings-path-manager Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
staff-service Fixed the test 2023-01-30 12:45:28 +00:00
stats-service Update dependency knex to v2.4.2 2023-01-23 13:00:53 +01:00
stripe Added version information to log lines 2023-01-20 13:18:44 +01:00
tiers Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
update-check-service Added version information to log lines 2023-01-20 13:18:44 +01:00
verification-trigger Improved email verification required checks (#16060) 2023-01-04 11:22:12 +01:00
version-notifications-data-service Limited integrations triggering version mismatch emails 2023-01-30 17:57:14 +08:00
webmentions completely blocked external requests in Webmentions tests (#16186) 2023-01-25 10:43:57 -06:00