|
16 | 16 | package com.spectralogic.ds3client.helpers.strategy.transferstrategy; |
17 | 17 |
|
18 | 18 | import com.google.common.collect.ImmutableCollection; |
| 19 | +import com.google.common.collect.ImmutableList; |
19 | 20 | import com.google.common.collect.ImmutableMap; |
20 | 21 | import com.google.common.collect.ImmutableMultimap; |
21 | 22 | import com.spectralogic.ds3client.exceptions.ContentLengthNotMatchException; |
|
25 | 26 | import com.spectralogic.ds3client.helpers.strategy.channelstrategy.ChannelStrategy; |
26 | 27 | import com.spectralogic.ds3client.models.BulkObject; |
27 | 28 | import com.spectralogic.ds3client.models.common.Range; |
| 29 | +import com.spectralogic.ds3client.utils.Guard; |
28 | 30 |
|
29 | 31 | import java.io.IOException; |
30 | 32 | import java.util.HashMap; |
@@ -125,12 +127,24 @@ private ImmutableCollection<Range> initializeRanges(final BulkObject blob, final |
125 | 127 |
|
126 | 128 | if (ranges == null) { |
127 | 129 | final long numBytesTransferred = 0; |
128 | | - ranges = updateRanges(ranges, numBytesTransferred, blob.getLength()); |
| 130 | + ranges = adjustRangesForBlobOffset(updateRanges(ranges, numBytesTransferred, blob.getLength()), blob); |
129 | 131 | } |
130 | 132 |
|
131 | 133 | return ranges; |
132 | 134 | } |
133 | 135 |
|
| 136 | + private ImmutableCollection<Range> adjustRangesForBlobOffset(final ImmutableCollection<Range> ranges, final BulkObject blob) { |
| 137 | + if (Guard.isNullOrEmpty(ranges) || ranges.size() > 1) { |
| 138 | + return ranges; |
| 139 | + } |
| 140 | + |
| 141 | + final Range firstRange = ranges.iterator().next(); |
| 142 | + |
| 143 | + final long blobOffset = blob.getOffset(); |
| 144 | + |
| 145 | + return ImmutableList.of(new Range(firstRange.getStart() + blobOffset, firstRange.getEnd() + blobOffset)); |
| 146 | + } |
| 147 | + |
134 | 148 | private ImmutableCollection<Range> updateRanges(final ImmutableCollection<Range> ranges, |
135 | 149 | final long numBytesTransferred, |
136 | 150 | final Long numBytesToTransfer) |
|
0 commit comments