Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 183aef5

Browse files
committed
Fix error when reading file using an unsatisifable range
1 parent 9bf1bda commit 183aef5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/org/cryptomator/cloudaccess/api/CloudProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ default CompletionStage<InputStream> read(CloudPath file, ProgressListener progr
102102
* @param offset The first byte (inclusive) to read.
103103
* @param count The number of bytes requested. Can exceed the actual file length. Set to {@link Long#MAX_VALUE} to read till EOF.
104104
* @param progressListener TODO Future use
105-
* @return CompletionStage with an InputStream to read from. If accessing the file fails, it'll complete exceptionally.
105+
* @return CompletionStage with an InputStream to read from. If accessing the file fails, it'll complete exceptionally. If the requested range cannot be fulfilled, an inputstream with 0 bytes is returned
106106
*/
107107
CompletionStage<InputStream> read(CloudPath file, long offset, long count, ProgressListener progressListener);
108108

src/main/java/org/cryptomator/cloudaccess/webdav/WebDavClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ private InputStream read(final Request.Builder getRequest, final ProgressListene
153153
try {
154154
response = httpClient.execute(getRequest);
155155
final var countingBody = new ProgressResponseWrapper(response.body(), progressListener);
156+
157+
final int UNSATISFIABLE_RANGE = 416;
158+
if(response.code() == UNSATISFIABLE_RANGE) {
159+
success = true;
160+
return new ByteArrayInputStream(new byte[0]);
161+
}
162+
156163
checkExecutionSucceeded(response.code());
157164
success = true;
158165
return countingBody.byteStream();

0 commit comments

Comments
 (0)