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

FilesByMd5Service: in addition to confirming that a file exists before including it in the array #call returns, confirm that the file is of the expected size #935

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

jmartin-sul
Copy link
Member

fixes sul-dlss/dor-services-app#5191

assumes size metadata will always be present, but that seems like a safe bet?

…e including it in the array #call returns, confirm that the file is of the expected size

fixes sul-dlss/dor-services-app#5191
@@ -24,12 +24,17 @@ def shelve_file_map

# @return [Array<Hash<String, String>>] array of hashes with md5 as key and filename as value for shelved files
# For example: [
# { "5b79c8570b7ef582735f912aa24ce5f2" => "2542A.tiff" },
# { "cd5ca5c4666cfd5ce0e9dc8c83461d7a" => "2542A.jp2" }
# { "5b79c8570b7ef582735f912aa24ce5f2" => { "filename" => "2542A.tiff", "size" => 456 } },
Copy link
Contributor

Choose a reason for hiding this comment

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

I now regret the original data structure which has morphed into ^^. To avoid confusing our future selves, can we define a struct (or similar) to hold file details (with md5, filename, and size attributes) and then return an array of file details?

Copy link
Contributor

Choose a reason for hiding this comment

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

(Happy to discuss more / pair.)

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, that makes sense to me. will give it a shot and discuss more or ask for pairing if i get stuck

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, this is ready for another review. i definitely prefer things with the struct suggestion, feels easier to read than the one element hash. left the change as a separate commit so that it'd be easy to undo if the change i made wasn't what you had in mind.

i realized after i finished that commit that i didn't switch FilesByMd5Service.call from returning the md5 keyed hash list, but i guess since the return value gets used in a controller that other services presumably depend on, best to leave that structure as is?

… a FileDetails struct instead of a hash keyed on md5 (has was always one element and no lookup was ever done)
Copy link
Contributor

@justinlittman justinlittman left a comment

Choose a reason for hiding this comment

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

Thanks for making the change @jmartin-sul .

@jmartin-sul
Copy link
Member Author

passed integration tests, merging

@jmartin-sul jmartin-sul merged commit 6234e6b into main Oct 25, 2024
2 checks passed
@jmartin-sul jmartin-sul deleted the omit-incomplete-files branch October 25, 2024 20:28
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.

Retry shelving a file if the file size on /stacks doesn't match the original file
2 participants