-
Notifications
You must be signed in to change notification settings - Fork 359
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
Handle spaces in file names in the import scripts #4189
Open
dltj
wants to merge
3
commits into
vufind-org:release-10.1
Choose a base branch
from
dltj:fix-spaces-in-marc-files
base: release-10.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have gotten indented an extra two spaces for some reason...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, since this script is largely the work of others and my bash expertise is limited, I may just be confused... but I thought the purpose of some of this code was to pass multiple matching files to the import script at once in a space-delimited list. How do we get around confusion between space-delimited files and files containing spaces? Is the find command smart enough to quote things appropriately for us? Do you need me to try to set up any edge case test scenarios to confirm proper functionality, or have you already done so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are mostly dealing with the output of the
find
command for filenames that have spaces in them. If one puts a filename with spaces (properly escaped) on the command line itself, it works okay. The-print0
option from the find command separates file entries by null characters...that was already there. The rest of the changes deal with handling that correctly. The script had some notable pitfalls when handling filenames with spaces...notably the use of thefor
control flow command. Needing to double-quote variable names that deal with values with spaces is also a notable pitfall.This is working in production for me now. I'm not sure how we'd set up a test with 'bash' and hook it up to the PHP test harness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wanted an automated test of this, we could create a directory containing MARC records with unusual filenames, and then run a batch import of this directory as part of the build.xml MARC indexing process. Then we would need a Mink test to confirm that the records actually exist in the index. A bit roundabout and complicated, and very possibly not worth the effort, but that's how I would approach it if I had to. (I'm perfectly content to just do some manual testing of my own when time permits, unless you're eager to automate something in the meantime).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go the manual testing route, and I'll post a message to Slack to get others to look at this. Normally I'd be up for learning new tools, but it is feeling like such a crunch time at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I tried some manual testing, and nothing seems to be working for me... but maybe I'm operating on incorrect assumptions. Here's what I did:
1.) I created two test directories under
$VUFIND_LOCAL_DIR/harvest
:$VUFIND_LOCAL_DIR/harvest/marc
and$VUFIND_LOCAL_DIR/harvest/marc records
, so I could run tests with or without a space in the harvest directory name.2.) I copied the same two sample records from the test data into both of these directories. I copied
testbug2.mrc
as is (for a "normal" filename example) and I copiedjournals.mrc
asjournal data.mrc
to introduce a filename containing a space.Here's what happens when I try to run the batch import on these two directories:
"marc" example:
"marc records" example:
Are you seeing different results?
Also, I notice that you have targeted the release-10.1 branch here; if you feel strongly that this is a bug fix, I'm not entirely opposed to going forward on that path... but since the changes are significant, maybe it would be more conservative to target this against dev for inclusion in release 11.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I hadn't considered a space in the directory name, only the file name of the records to be loaded. To be honest, I hadn't looked at the handling of spaces in the directory name...there are probably pitfalls there, too. Does it change your test results if you use a directory with no spaces in it?
I'm happy to target this against dev for inclusion in the next release. I could go either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm still seeing the same behavior as noted above for the
marc
directory containingtestbug2.mrc
andjournal data.mrc
. Looks to me from the error message like the path to the directory containing the file is somehow getting lost and the code is trying to find it in the root directory.