JCLOUDS-1371: JCLOUDS-1488: optimize fs prefix

This reduces the number of stat calls required when prefix is deep in the
filesystem hierarchy.  Further optimizations to delimiter are possible.
References gaul/s3proxy#473.
This commit is contained in:
Andrew Gaul
2022-12-26 15:39:27 +09:00
committed by Andrew Gaul
parent 7e50ae630d
commit e478dd5452
@@ -353,6 +353,14 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
File containerFile = openFolder(container);
final int containerPathLength = containerFile.getAbsolutePath().length() + 1;
if (prefix != null) {
// prefix may end with a partial directory so only list the complete parent
int index = prefix.lastIndexOf('/');
if (index != -1) {
containerFile = new File(containerFile, prefix.substring(0, index + 1));
}
}
populateBlobKeysInContainer(containerFile, blobNames, prefix, new Function<String, String>() {
@Override
public String apply(String string) {