Skip to content

Commit

Permalink
do not remove md in DelimeterFilter then add it by commonPrefixes; ju…
Browse files Browse the repository at this point in the history
…st keep it
  • Loading branch information
jixinchi committed Nov 13, 2023
1 parent 47e3022 commit 5069720
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ private SortedSet<StorageMetadata> extractCommonPrefixes(SortedSet<StorageMetada
o = prefix + o;
}
md.setName(o + delimiter);
if (!contents.contains(md)) {
contents.add(md);
}
contents.add(md);
}
return contents;
Expand Down Expand Up @@ -471,15 +474,15 @@ public DelimiterFilter(String prefix, String delimiter) {
public boolean apply(StorageMetadata metadata) {
String name = metadata.getName();
if (prefix == null || prefix.isEmpty()) {
return name.indexOf(delimiter) == -1;
return name.indexOf(delimiter) == -1 || name.indexOf(delimiter) == name.length() - delimiter.length();
}
if (name.startsWith(prefix)) {
String unprefixedName = name.substring(prefix.length());
if (unprefixedName.equals("")) {
// a blob that matches the prefix should also be returned
return true;
}
return unprefixedName.indexOf(delimiter) == -1;
return unprefixedName.indexOf(delimiter) == -1 || unprefixedName.indexOf(delimiter) == unprefixedName.length() - delimiter.length();
}
return false;
}
Expand All @@ -505,7 +508,7 @@ public String apply(StorageMetadata metadata) {
}
}
if (working.indexOf(delimiter) >= 0) {
// include the delimiter in the result
// not include the delimiter in the result
return working.substring(0, working.indexOf(delimiter));
} else {
return NO_PREFIX;
Expand Down

0 comments on commit 5069720

Please sign in to comment.