kopia lustrzana https://github.com/gaul/s3proxy
Partially emulate arbitrary markers with GCS
S3 supports arbitrary keys for the marker while GCS only supports its opaque marker. Emulate the common case for GCS by mapping the last key from a listing to the corresponding previously returned marker.pull/78/head
rodzic
19aa01c090
commit
50871a55ec
|
@ -158,6 +158,11 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
"bucket-owner-full-control",
|
"bucket-owner-full-control",
|
||||||
"log-delivery-write"
|
"log-delivery-write"
|
||||||
);
|
);
|
||||||
|
/** Blobstores with opaque markers. */
|
||||||
|
private static final Set<String> BLOBSTORE_OPAQUE_MARKERS = ImmutableSet.of(
|
||||||
|
"azureblob",
|
||||||
|
"google-cloud-storage"
|
||||||
|
);
|
||||||
|
|
||||||
private final boolean anonymousIdentity;
|
private final boolean anonymousIdentity;
|
||||||
private final Optional<String> virtualHost;
|
private final Optional<String> virtualHost;
|
||||||
|
@ -169,9 +174,10 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
// TODO: hack to allow per-request anonymous access
|
// TODO: hack to allow per-request anonymous access
|
||||||
private final BlobStore defaultBlobStore;
|
private final BlobStore defaultBlobStore;
|
||||||
/**
|
/**
|
||||||
* S3 supports arbitrary keys for the marker while Azure only supports its
|
* S3 supports arbitrary keys for the marker while some blobstores only
|
||||||
* opaque marker. Emulate the common case for Azure by mapping the last
|
* support opaque markers. Emulate the common case for these by mapping
|
||||||
* key from a listing to the corresponding previously returned marker.
|
* the last key from a listing to the corresponding previously returned
|
||||||
|
* marker.
|
||||||
*/
|
*/
|
||||||
private final Cache<Map.Entry<String, String>, String> lastKeyToMarker =
|
private final Cache<Map.Entry<String, String>, String> lastKeyToMarker =
|
||||||
CacheBuilder.newBuilder()
|
CacheBuilder.newBuilder()
|
||||||
|
@ -874,7 +880,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
String marker = request.getParameter("marker");
|
String marker = request.getParameter("marker");
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
if (blobStoreType.equals("azureblob")) {
|
if (BLOBSTORE_OPAQUE_MARKERS.contains(blobStoreType)) {
|
||||||
String realMarker = lastKeyToMarker.getIfPresent(
|
String realMarker = lastKeyToMarker.getIfPresent(
|
||||||
Maps.immutableEntry(containerName, marker));
|
Maps.immutableEntry(containerName, marker));
|
||||||
if (realMarker != null) {
|
if (realMarker != null) {
|
||||||
|
@ -930,7 +936,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
if (nextMarker != null) {
|
if (nextMarker != null) {
|
||||||
writeSimpleElement(xml, "IsTruncated", "true");
|
writeSimpleElement(xml, "IsTruncated", "true");
|
||||||
writeSimpleElement(xml, "NextMarker", nextMarker);
|
writeSimpleElement(xml, "NextMarker", nextMarker);
|
||||||
if (blobStoreType.equals("azureblob")) {
|
if (BLOBSTORE_OPAQUE_MARKERS.contains(blobStoreType)) {
|
||||||
lastKeyToMarker.put(Maps.immutableEntry(containerName,
|
lastKeyToMarker.put(Maps.immutableEntry(containerName,
|
||||||
Iterables.getLast(set).getName()), nextMarker);
|
Iterables.getLast(set).getName()), nextMarker);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue