Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload check #997

Merged
merged 4 commits into from
Dec 31, 2023
Merged

Upload check #997

merged 4 commits into from
Dec 31, 2023

Conversation

70ray
Copy link
Collaborator

@70ray 70ray commented Dec 26, 2023

This makes a checksum for the uploaded file, uploads it and checks it with the file received by the server.
The javascript function is based on the example in this mozilla document reworked for the browsers we support which cannot use async, await, File.arrayBuffer() or String.padStart().
This checking should not really be necessary because lower levels of the internet protocol should already validate data but two users have encountered errors given by the zip validator so this is intended to discover if the problem is caused by data corruption or something else.
The change to upload_resumable_file.php is recommended in the resumable docs to avoid unnecessary error messages in the console.

Sandbox at: https://www.pgdp.org/~rp31/c.branch/upload_check

change header code to 204 to avoid spurious error messages
@70ray 70ray mentioned this pull request Dec 26, 2023
@cpeel
Copy link
Member

cpeel commented Dec 26, 2023

The change to upload_resumable_file.php is recommended in the resumable docs to avoid unnecessary error messages in the console.

Looks like the original website and repo for this went away. Were you able to find another copy somewhere that we can update pinc/3rdparty/resumablejs/README.md?

@70ray
Copy link
Collaborator Author

70ray commented Dec 26, 2023

The change to upload_resumable_file.php is recommended in the resumable docs to avoid unnecessary error messages in the console.

Looks like the original website and repo for this went away. Were you able to find another copy somewhere that we can update pinc/3rdparty/resumablejs/README.md?

The one I looked at has gone away now. this one seems to have the same information.

});
}

// polyfill for String.padStart(2, "0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we would have to support Chrome 57 but we only do 54

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that. I'm fine with keeping this, but do we know why we support chrome 54 specifically? Was it the last versino supported on xp or something like that? It was released in 2016.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. According to browserstack xp only supports chrome 49. xp supports firefox 52 which is the reason for that and firefox 52 does PadStart.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DP's supported browser list was last updated two-ish years ago in October of 2021. See Supported Browsers, and note the comment about Safari, Chrome and Opera on macOS: I couldn't find an official end-of-life schedule for macOS, but it looks like a three-year cycle. Big Sur (macOS 11) is no longer supported now.

How rigorous do we want to be in updating our supported browser list?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not boil the ocean, for this PR I think we should bump our minimum Chrome version to 57 and drop the polyfill. Based on the platform support numbers for Chrome 52 -> 57 doesn't cross any threshold and seems very sensible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to revisit all of our minimum browser versions if we need to, but it doesn't sound like this warrants that extra effort.

@@ -23,6 +23,42 @@ window.addEventListener("DOMContentLoaded", function() {
return true;
}

// polyfill for file.arrayBuffer()
function fileToArrayBuffer(file) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's File:arrayBuffer() we need which seems to be same as Blob: arrayBuffer() which is not supported by any of the browsers we can use.

showProgress(uploadMessages.working);
ev.preventDefault();
fileHash(file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want a .catch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We should. Perhaps just upload an empty string in this case and let the server say there was no checksum provided.

@cpeel
Copy link
Member

cpeel commented Dec 26, 2023

The change to upload_resumable_file.php is recommended in the resumable docs to avoid unnecessary error messages in the console.

Looks like the original website and repo for this went away. Were you able to find another copy somewhere that we can update pinc/3rdparty/resumablejs/README.md?

The one I looked at has gone away now. this one seems to have the same information.

As luck would have it, I actually have a checkout of the old repo on TEST. And I found https://github.com/QuanTemplate/resumable.js/commits/master/ which appears to be a newer fork of the original repo (last commit is by original repo owner). I'll get a fork of that made in DistributedProofreaders so we have it.

@cpeel
Copy link
Member

cpeel commented Dec 26, 2023

We now have a fork in https://github.com/DistributedProofreaders/resumable.js with an updated README.md about its lineage for future reference.

Copy link
Member

@cpeel cpeel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to whoever merges this in (maybe me): bump our minimum Chrome version to 57 upon merge.

@70ray
Copy link
Collaborator Author

70ray commented Dec 27, 2023

Sandbox updated.

@70ray
Copy link
Collaborator Author

70ray commented Dec 27, 2023

We should also bump minimum Safari version from 10 to 11 and Opera from 41 to 44.
I just tried the older versions and chrome 54 on browserstack and they upload the file without any problems but the server says "No checksum provided".

@srjfoo
Copy link
Member

srjfoo commented Dec 31, 2023

We should also bump minimum Safari version from 10 to 11 and Opera from 41 to 44. I just tried the older versions and chrome 54 on browserstack and they upload the file without any problems but the server says "No checksum provided".

Minimum version for Safari is already at 11. And confirmed the other two.

I was already checking out browserstack, because I was thinking I still needed to be checking out the broken non-resumable issue (only to discover that I had to go to XP on a browser no longer supported to be able to find a browser version that didn't support resumables (of the browsers that we support). And I didn't get an error message from it.

@cpeel cpeel merged commit 1795474 into DistributedProofreaders:master Dec 31, 2023
4 checks passed
@cpeel
Copy link
Member

cpeel commented Dec 31, 2023

https://www.pgdp.net/wiki/DP_Official_Documentation:General/Supported_Browsers has been updated with the new minimum versions.

@70ray 70ray deleted the upload_check branch January 1, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants