mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-20 22:39:55 +08:00
decompress after decrypt if necessary
skip any decompress error
This commit is contained in:
@@ -18,14 +18,18 @@ public class Gzip {
|
|||||||
return compressed;
|
return compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] decompress(byte[] compressed) throws IOException {
|
public static byte[] decompress(byte[] compressed) {
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
|
try {
|
||||||
GZIPInputStream gis = new GZIPInputStream(bis);
|
ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
|
||||||
return readAll(gis);
|
GZIPInputStream gis = new GZIPInputStream(bis);
|
||||||
|
return readAll(gis);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return compressed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] readAll(InputStream input) throws IOException {
|
private static byte[] readAll(InputStream input) throws IOException {
|
||||||
try( ByteArrayOutputStream output = new ByteArrayOutputStream()){
|
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
|
||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
int n;
|
int n;
|
||||||
while (-1 != (n = input.read(buffer))) {
|
while (-1 != (n = input.read(buffer))) {
|
||||||
|
@@ -119,6 +119,10 @@ public class SeaweedRead {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chunkView.isCompressed) {
|
||||||
|
data = Gzip.decompress(data);
|
||||||
|
}
|
||||||
|
|
||||||
LOG.debug("doFetchFullChunkData fid:{} chunkData.length:{}", chunkView.fileId, data.length);
|
LOG.debug("doFetchFullChunkData fid:{} chunkData.length:{}", chunkView.fileId, data.length);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Reference in New Issue
Block a user