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

Fix #725, partial filename match for downloading fails #959

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

plocket
Copy link
Collaborator

@plocket plocket commented Nov 21, 2024

The failure is actually during the comparison - the file was being saved using the partial name the author gave in the Step when it should have been using the file's downloaded name.

Close #725

Note that our current download method will, in ideal cases, let an author re-name the downloaded file. Since it might not be consistent, we might still avoid implementing this at this point. Also, in ideal cases, the Step does already continue without waiting for the whole file to download, which addresses #492. That happened a while ago. It's worth considering closing that issue at this point. We have to research under what circumstances a file would fail to download with a fetch while still being able to download with a click. Maybe with an encrypted interview.

In this PR, I have:

  • Added tests for any new features or bug fixes (if relevant)
  • Added my changes to the CHANGELOG.md at the top, under the "Unreleased" section
  • Ensured issues that this PR closes will be automatically closed

Reason for this PR

When using the "download" Step, authors use a filename to get the file link from the page. For example, "my_file.pdf". They are also supposed to be able to use a partial file name to match the file name - "my_fi" should work just as well. That seemed to cause problems, though.

Exploring the problem showed that the real problem was when comparing the downloaded PDF to a baseline PDF. An author would download "my_fi" and then compare "my_file.pdf" with "basline_file.pdf". The comparison would fail because "my_file.pdf" was missing.

The problem was that ALKiln was saving the downloaded file using the partial-match name, not the file's actual name. That is, ALKiln would save a file called "my_fi". Then, when ALKiln tried to find "my_file.pdf" for the comparison, it would only find "my_fi" and the comparison would fail.

This PR now uses the name that the download file gives in the response.headers.

Note: We might need to improve the message when ALKiln can't find the downloaded file. It wasn't clear about what happened. I might add that to the PR

Also see #725

Links to any solved or related issues

Close #725

Any manual testing I have done to ensure my PR is working

N/A

Copy link
Collaborator

@BryceStevenWilley BryceStevenWilley left a comment

Choose a reason for hiding this comment

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

Looks good to me! The variable name change is the only thing I see that could improve things

lib/scope.js Outdated
@@ -2781,7 +2781,7 @@ module.exports = {
await scope.afterStep(scope);
}, // Ends scope.steps.sign()

download: async ( scope, filename ) => {
download: async ( scope, filename_matcher ) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

filename_matcher to me implies that it's some more powerful lambda function or regex or something, and not just a partial string. Maybe partial_filename would be better.

The failure is actually during the comparison - the file was being
saved using the partial name the author gave in the Step when
it should have been using the file's downloaded name.

Note that our current download method will, in ideal cases, let an
author re-name the downloaded file. Since it might not be
consistent, we might still avoid implementing this at this point.
Also, in ideal cases, the Step does already continue without
waiting for the whole file to download, which addresses #492. That
happened a while ago. It's worth considering closing that issue at
this point. We have to research under what circumstances a file
would fail to download with a `fetch` while still being able to
download with a click. Maybe with an encrypted interview.

Co-authored-by: ethanstrominger <ethanstrominger2@gmail.com>
@plocket plocket merged commit 924e6f8 into v5 Nov 23, 2024
7 checks passed
@plocket plocket deleted the 725_download_match branch November 23, 2024 15:48
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.

File download Step with partial name doesn't get provided in output
2 participants