upload: Fix uploading the same file twice in the same session.

This commit fixes a bug where uploading the same file a second time
in the same browser session would appear to the user to stall with
`Uploading [filename]...` in the composebox.  This is because
`tus-js-client` makes a HEAD request to check for already-uploaded
files -- and, if found, that request is used in the `upload-success`
callback.  That left the callback with no response body to parse, to
know what URL to insert.

Store the `/user_uploads/...` URL in the file metadata after a
successful upload, and if the fingerprint matches a previous upload,
pull that URL (and filename, as it may have changed server-side) out
of the previous upload's metadata.

Co-authored-by: Shubham Padia <shubham@zulip.com>
(cherry picked from commit c2e0a27d2c)
This commit is contained in:
Alex Vandiver
2025-05-27 20:39:28 +00:00
committed by Tim Abbott
parent cfa6e41691
commit ba5f68c155
5 changed files with 108 additions and 29 deletions

View File

@@ -49,4 +49,4 @@ API_FEATURE_LEVEL = 372 # Last bumped to interpret "(no topic)" as empty string
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
PROVISION_VERSION = (323, 0) # bumped 2025-05-04 to upgrade Python requirements
PROVISION_VERSION = (323, 1) # bumped 2025-06-25 to add @uppy/utils