Skip to content

BagLinter always adds 'different_case' warning #119

@rvanheest

Description

@rvanheest

I just upgraded to v1.2.0 of this library. With the upgraded stuff on BagIt v1.0 in #118, a new bug has entered the library:

When using the BagLinter, the warning different_case will always be shown. Given it's description:

The bag contains two files that differ only in case. This can cause problems on a filesystem like the one used by apple (HFS).

I would not expect this to happen on a bag with only very distinct files.

I think the bug is as follows: in the code below a manifest file is read and for each line the path is added to the Set paths (after being converted to lowercase).

try(final BufferedReader reader = Files.newBufferedReader(manifestFile, encoding)){
final Set<String> paths = new HashSet<>();
String line = reader.readLine();
while(line != null){
String path = parsePath(line);
path = checkForManifestCreatedWithMD5SumTools(path, warnings, warningsToIgnore);
paths.add(path.toLowerCase());
checkForDifferentCase(path, paths, manifestFile, warnings, warningsToIgnore);
if(encoding.name().startsWith("UTF")){
checkNormalization(path, manifestFile.getParent(), warnings, warningsToIgnore);
}
checkForBagWithinBag(line, warnings, warningsToIgnore, isPayloadManifest);
checkForRelativePaths(line, warnings, warningsToIgnore, manifestFile);
checkForOSSpecificFiles(line, warnings, warningsToIgnore, manifestFile);
line = reader.readLine();
}
}

Immediately after that checkForDifferentCase is called, which checks whether paths.contains(path.toLowerCase()). Of course, this is always true, since path was just added to paths before this check.

/*
* Check that the same line doesn't already exist in the set of paths
*/
private static void checkForDifferentCase(final String path, final Set<String> paths, final Path manifestFile,
final Set<BagitWarning> warnings, final Collection<BagitWarning> warningsToIgnore){
if(!warningsToIgnore.contains(BagitWarning.DIFFERENT_CASE) && paths.contains(path.toLowerCase())){
logger.warn(messages.getString("different_case_warning"), manifestFile, path);
warnings.add(BagitWarning.DIFFERENT_CASE);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions