as per the proposed spec, allow for payload-oxum to be in bagit.txt#80
as per the proposed spec, allow for payload-oxum to be in bagit.txt#80johnscancella wants to merge 4 commits intomasterfrom
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.
(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.
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.
👍 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.
| 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.
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