Skip to content

Commit

Permalink
compress stream with lz4
Browse files Browse the repository at this point in the history
  • Loading branch information
hexian000 committed Apr 28, 2018
1 parent 4320333 commit 88ac6e3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
// https://mvnrepository.com/artifact/org.apache.commons/commons-compress
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.16.1'
// https://mvnrepository.com/artifact/org.objenesis/objenesis
compileOnly group: 'org.objenesis', name: 'objenesis', version: '2.6'
}
5 changes: 5 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-dontwarn sun.misc.**
-dontwarn org.tukaani.xz.**
-dontwarn org.brotli.dec.**
-dontwarn com.github.luben.zstd.**
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import me.hexian000.masstransfer.io.DirectoryWriter;
import me.hexian000.masstransfer.io.Pipe;
import me.hexian000.masstransfer.io.RateCounter;
import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorInputStream;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -176,7 +177,7 @@ private void runPipe(Socket socket) throws InterruptedException, IOException {
Thread writerThread = new Thread(writer);
writerThread.start();
Timer timer = new Timer();
try (InputStream in = socket.getInputStream()) {
try (InputStream in = new FramedLZ4CompressorInputStream(socket.getInputStream(), true)) {
RateCounter rate = new RateCounter();
final int rateInterval = 2;
timer.schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import me.hexian000.masstransfer.io.DirectoryReader;
import me.hexian000.masstransfer.io.Pipe;
import me.hexian000.masstransfer.io.RateCounter;
import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorOutputStream;

import java.io.IOException;
import java.io.OutputStream;
Expand Down Expand Up @@ -160,7 +161,7 @@ private void runPipe(Socket socket) {
Thread readerThread = new Thread(reader);
readerThread.start();
Timer timer = new Timer();
try (OutputStream out = socket.getOutputStream()) {
try (OutputStream out = new FramedLZ4CompressorOutputStream(socket.getOutputStream())) {
RateCounter rate = new RateCounter();
final int rateInterval = 10;
timer.schedule(new TimerTask() {
Expand Down

0 comments on commit 88ac6e3

Please sign in to comment.