Skip to content

Commit

Permalink
Merge pull request #313 from Nizernizer/main
Browse files Browse the repository at this point in the history
fix bug: High memory usage
  • Loading branch information
Nizernizer authored May 18, 2022
2 parents a5f4f78 + 88d27b6 commit 3352d46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import io.dongtai.log.DongTaiLog;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand All @@ -21,12 +18,13 @@ public static String getSignature(InputStream is, String algorithm) {
String signature = null;
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
byte[] buffer = new byte[1024 * 1024 * 10];
byte[] buffer = new byte[1024];

int len = 0;
while ((len = is.read(buffer)) > 0) {
digest.update(buffer, 0, len);
}
buffer = null;
BigInteger bigInteger = new BigInteger(1, digest.digest());
signature = String.format("%040x", bigInteger);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public void send() {
}

public String genDirTree(String path, int level, String dir) {
// fixme: 防止目录过长导致启动卡死,后续对目录长度需讨论。
if(dirStringBuilder.length()>65536){
return dirStringBuilder.toString();
}
level++;
File file = new File(path);
File[] files = file.listFiles();
Expand Down

0 comments on commit 3352d46

Please sign in to comment.