Skip to content

Commit b693411

Browse files
committed
Report download abort due to max size correctly
1 parent e58661f commit b693411

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/net/litetex/capes/provider/CapeProvider.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,16 @@ static ResolvedTextureInfo.ByteArrayTextureInfo resolveTextureDefault(
8686
.setMaxCount(DEFAULT_MAX_DOWNLOAD_BYTES)
8787
.get())
8888
{
89-
return new ResolvedTextureInfo.ByteArrayTextureInfo(
90-
IOUtils.toByteArray(cappedIS),
91-
textureResolverId);
89+
final ResolvedTextureInfo.ByteArrayTextureInfo byteArrayTextureInfo =
90+
new ResolvedTextureInfo.ByteArrayTextureInfo(
91+
IOUtils.toByteArray(cappedIS),
92+
textureResolverId);
93+
if(cappedIS.getCount() >= DEFAULT_MAX_DOWNLOAD_BYTES)
94+
{
95+
throw new IllegalStateException(
96+
"Aborted download because it exceeded the maximum allowed size: " + DEFAULT_MAX_DOWNLOAD_BYTES);
97+
}
98+
return byteArrayTextureInfo;
9299
}
93100
}
94101
}

0 commit comments

Comments
 (0)