kopia lustrzana https://github.com/gaul/s3proxy
More consistently use Path objects
This improves compatibility on Windows. References #740.pull/719/head
rodzic
b523c448a1
commit
1e6763e574
|
@ -179,10 +179,10 @@ public abstract class AbstractNio2BlobStore extends BaseBlobStore {
|
||||||
} else {
|
} else {
|
||||||
prefix = "";
|
prefix = "";
|
||||||
}
|
}
|
||||||
prefix = "/" + container + "/" + prefix;
|
var pathPrefix = root.resolve(container).resolve(prefix);
|
||||||
var set = ImmutableSortedSet.<StorageMetadata>naturalOrder();
|
var set = ImmutableSortedSet.<StorageMetadata>naturalOrder();
|
||||||
try {
|
try {
|
||||||
listHelper(set, container, dirPrefix, prefix, delimiter);
|
listHelper(set, container, dirPrefix, pathPrefix, delimiter);
|
||||||
var sorted = set.build();
|
var sorted = set.build();
|
||||||
if (options.getMarker() != null) {
|
if (options.getMarker() != null) {
|
||||||
var found = false;
|
var found = false;
|
||||||
|
@ -217,7 +217,7 @@ public abstract class AbstractNio2BlobStore extends BaseBlobStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listHelper(ImmutableSortedSet.Builder<StorageMetadata> builder,
|
private void listHelper(ImmutableSortedSet.Builder<StorageMetadata> builder,
|
||||||
String container, Path parent, String prefix, String delimiter)
|
String container, Path parent, Path prefix, String delimiter)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
logger.debug("recursing at: {} with prefix: {}", parent, prefix);
|
logger.debug("recursing at: {} with prefix: {}", parent, prefix);
|
||||||
if (!Files.isDirectory(parent)) { // TODO: TOCTOU
|
if (!Files.isDirectory(parent)) { // TODO: TOCTOU
|
||||||
|
@ -226,7 +226,7 @@ public abstract class AbstractNio2BlobStore extends BaseBlobStore {
|
||||||
try (var stream = Files.newDirectoryStream(parent)) {
|
try (var stream = Files.newDirectoryStream(parent)) {
|
||||||
for (var path : stream) {
|
for (var path : stream) {
|
||||||
logger.debug("examining: {}", path);
|
logger.debug("examining: {}", path);
|
||||||
if (!path.toAbsolutePath().toString().startsWith(root + prefix)) {
|
if (!path.toAbsolutePath().toString().startsWith(root.resolve(prefix).toAbsolutePath().toString())) {
|
||||||
// ignore
|
// ignore
|
||||||
} else if (Files.isDirectory(path)) {
|
} else if (Files.isDirectory(path)) {
|
||||||
if (!"/".equals(delimiter)) {
|
if (!"/".equals(delimiter)) {
|
||||||
|
|
Ładowanie…
Reference in New Issue