decompress after decrypt if necessary

skip any decompress error
This commit is contained in:
Chris Lu
2020-08-02 23:50:23 -07:00
parent 1b3a80dd3d
commit 0ed1f43d29
2 changed files with 13 additions and 5 deletions

View File

@@ -18,10 +18,14 @@ public class Gzip {
return compressed; return compressed;
} }
public static byte[] decompress(byte[] compressed) throws IOException { public static byte[] decompress(byte[] compressed) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(compressed); ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
GZIPInputStream gis = new GZIPInputStream(bis); GZIPInputStream gis = new GZIPInputStream(bis);
return readAll(gis); return readAll(gis);
} catch (Exception e) {
return compressed;
}
} }
private static byte[] readAll(InputStream input) throws IOException { private static byte[] readAll(InputStream input) throws IOException {

View File

@@ -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;