mirror of https://github.com/apache/jclouds.git
Handle when total length is less than part length
This commit is contained in:
parent
a67ae3f27b
commit
bc1f12b7bd
|
@ -43,6 +43,7 @@ public final class MultipartUploadSlicingAlgorithm {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int DEFAULT_MAGNITUDE_BASE = 100;
|
static final int DEFAULT_MAGNITUDE_BASE = 100;
|
||||||
|
|
||||||
|
// TODO: these are not injected
|
||||||
@Inject(optional = true)
|
@Inject(optional = true)
|
||||||
@Named("jclouds.mpu.parts.size")
|
@Named("jclouds.mpu.parts.size")
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -108,6 +109,11 @@ public final class MultipartUploadSlicingAlgorithm {
|
||||||
unitPartSize = minimumPartSize; // take the minimum part size
|
unitPartSize = minimumPartSize; // take the minimum part size
|
||||||
parts = (int)(length / unitPartSize);
|
parts = (int)(length / unitPartSize);
|
||||||
}
|
}
|
||||||
|
if (parts == 0) {
|
||||||
|
partSize = length;
|
||||||
|
unitPartSize = length;
|
||||||
|
parts = 1;
|
||||||
|
}
|
||||||
if (parts > maximumNumberOfParts) { // if still splits in too many parts
|
if (parts > maximumNumberOfParts) { // if still splits in too many parts
|
||||||
parts = maximumNumberOfParts - 1; // limit them. do not care about not
|
parts = maximumNumberOfParts - 1; // limit them. do not care about not
|
||||||
// covering
|
// covering
|
||||||
|
|
|
@ -639,7 +639,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
blobStore.getMinimumMultipartPartSize(), blobStore.getMaximumMultipartPartSize(),
|
blobStore.getMinimumMultipartPartSize(), blobStore.getMaximumMultipartPartSize(),
|
||||||
blobStore.getMaximumNumberOfParts());
|
blobStore.getMaximumNumberOfParts());
|
||||||
// make sure that we are creating multiple parts
|
// make sure that we are creating multiple parts
|
||||||
assertThat(algorithm.calculateChunkSize(length)).isLessThan(length);
|
assertThat(algorithm.calculateChunkSize(length)).isLessThanOrEqualTo(length);
|
||||||
ByteSource byteSource = TestUtils.randomByteSource().slice(0, length);
|
ByteSource byteSource = TestUtils.randomByteSource().slice(0, length);
|
||||||
Payload payload = new ByteSourcePayload(byteSource);
|
Payload payload = new ByteSourcePayload(byteSource);
|
||||||
HashCode hashCode = byteSource.hash(Hashing.md5());
|
HashCode hashCode = byteSource.hash(Hashing.md5());
|
||||||
|
|
Loading…
Reference in New Issue