-
Notifications
You must be signed in to change notification settings - Fork 49
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
as per the proposed spec, allow for payload-oxum to be in bagit.txt #80
base: master
Are you sure you want to change the base?
Conversation
values.encoding = encoding; | ||
} | ||
if("Payload-Byte-Count".equals(pair.getKey())){ //assume version is 1.0+ | ||
logger.debug("Payload-Byte-Count is [{}]", pair.getKey()); |
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.
Shouldn't this be getValue?
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.
(and possibly the whole thing should be something like "{} is {}", pair.getKey(), pair.getValue()
?
values.payloadByteCount = Long.valueOf(pair.getValue()); | ||
} | ||
if("Payload-File-Count".equals(pair.getKey())){ //assume version is 1.0+ | ||
logger.debug("Payload-File-Count is [{}]", pair.getKey()); |
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.
See comment for payload byte count
|
||
if(bag.getPayloadByteCount() != null && bag.getPayloadFileCount() != null){ | ||
logger.debug("Found payload byte and file count, using that instead of payload-oxum"); | ||
//TODO check if it matches payload-oxum, and if not issue warning? |
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.
👍 on a warning - I was just looking to see what would happen if both are present or if they are and do not match. I would use the bagit.txt fields in preference but issue a validation error or possibly just a linter warning if Payload-Oxum doesn't match the more controlled fields.
@@ -41,5 +64,13 @@ public static void writeBagitFile(final Version version, final Charset encoding, | |||
final String secondLine = "Tag-File-Character-Encoding : " + encoding + System.lineSeparator(); | |||
logger.debug("Writing line [{}] to [{}]", secondLine, bagitPath); | |||
Files.write(bagitPath, secondLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE, StandardOpenOption.APPEND); | |||
|
|||
if(version.compareTo(ONE_DOT_ZERO) >= 0 && payloadByteCount != null && payloadFileCount != null){ //if it is 1.0 or greater | |||
final String thirdLine = "Payload-Byte-Count : " + payloadByteCount + System.lineSeparator(); |
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.
I'm wondering whether now is the right time to fix the naming convention here - firstLine
, et al. are making me itch a bit.
Also, looking at the Files.write
code, this is repeatedly opening the same file with a bunch of redundant options and the getBytes calls are being repeated on every line as well. Could all of this be collapsed into a single array with 2-4 lines for a single Files.write
call using the form which accepts text and the target output encoding?
only merge if https://github.com/loc-rdc/bagitspec/pull/2 is accepted