diff --git a/pom.xml b/pom.xml
index 4766a1280..b5ca6e055 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.tonikelope
MegaBasterd
- 7.70
+ 7.71
jar
diff --git a/src/main/java/com/tonikelope/megabasterd/FileMergerDialog.java b/src/main/java/com/tonikelope/megabasterd/FileMergerDialog.java
index d13d5bbfa..2d2b5281c 100644
--- a/src/main/java/com/tonikelope/megabasterd/FileMergerDialog.java
+++ b/src/main/java/com/tonikelope/megabasterd/FileMergerDialog.java
@@ -47,6 +47,7 @@ public class FileMergerDialog extends javax.swing.JDialog {
private String _file_name = null;
private long _file_size = 0L;
private volatile boolean _exit = false;
+ private volatile String _file_name_full;
/**
* Creates new form FileSplitterDialog
@@ -105,11 +106,11 @@ public class FileMergerDialog extends javax.swing.JDialog {
private boolean _mergeFile() throws IOException {
- try ( RandomAccessFile targetFile = new RandomAccessFile(this.file_name_label.getText(), "rw")) {
+ try ( RandomAccessFile targetFile = new RandomAccessFile(_file_name_full, "rw")) {
FileChannel targetChannel = targetFile.getChannel();
- monitorProgress(Paths.get(this.file_name_label.getText()));
+ monitorProgress(Paths.get(_file_name));
for (String file_path : this._file_parts) {
@@ -129,6 +130,23 @@ public class FileMergerDialog extends javax.swing.JDialog {
}
}
+ if (Files.exists(Paths.get(_file_name_full + ".sha1"))) {
+
+ String sha1 = Files.readString(Paths.get(_file_name_full + ".sha1")).trim();
+
+ MiscTools.GUIRunAndWait(() -> {
+ merge_button.setText("CHECKING FILE INTEGRITY, please wait...");
+ });
+
+ if (sha1.equals(MiscTools.computeFileSHA1(new File(_file_name_full)))) {
+ JOptionPane.showMessageDialog(this, LabelTranslatorSingleton.getInstance().translate("FILE INTEGRITY OK"));
+ return true;
+ } else {
+ JOptionPane.showMessageDialog(this, LabelTranslatorSingleton.getInstance().translate("FILE SEEMS TO BE CORRUPTED"), "VERIFICATION ERROR", JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ }
+
return true;
}
@@ -281,6 +299,8 @@ public class FileMergerDialog extends javax.swing.JDialog {
this._file_name = MiscTools.findFirstRegex("^(.+)\\.part[0-9]+\\-[0-9]+$", filechooser.getSelectedFile().getName(), 1);
+ this._file_name_full = MiscTools.findFirstRegex("^(.+)\\.part[0-9]+\\-[0-9]+$", filechooser.getSelectedFile().getAbsolutePath(), 1);
+
if (this._file_name != null) {
this.file_name_label.setText(truncateText(this._file_name, 150));
@@ -414,9 +434,9 @@ public class FileMergerDialog extends javax.swing.JDialog {
if (Desktop.isDesktopSupported()) {
try {
- Desktop.getDesktop().open(new File(file_name_label.getText()).getParentFile());
- } catch (IOException ex) {
-
+ Desktop.getDesktop().open(_output_dir);
+ } catch (Exception ex) {
+ Logger.getLogger(FileMergerDialog.class.getName()).log(Level.SEVERE, ex.getMessage());
}
}
@@ -462,7 +482,7 @@ public class FileMergerDialog extends javax.swing.JDialog {
pack();
});
}
- } catch (IOException ex) {
+ } catch (Exception ex) {
Logger.getLogger(FileMergerDialog.class.getName()).log(Level.SEVERE, ex.getMessage());
}
});
diff --git a/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java b/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
index 28ec09343..36eb77d0c 100644
--- a/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
+++ b/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
@@ -41,6 +41,7 @@ public class FileSplitterDialog extends javax.swing.JDialog {
private final MainPanel _main_panel;
private File[] _files = null;
private File _output_dir = null;
+ private volatile String _sha1=null;
private volatile long _progress = 0L;
private volatile Path _current_part = null;
private volatile int _current_file = 0;
@@ -84,6 +85,17 @@ public class FileSplitterDialog extends javax.swing.JDialog {
}
private boolean _splitFile(int i) throws IOException {
+
+ _sha1 = "";
+
+ THREAD_POOL.execute(() -> {
+
+ try {
+ _sha1 = MiscTools.computeFileSHA1(new File(_files[i].getAbsolutePath()));
+ } catch (IOException ex) {
+ Logger.getLogger(FileSplitterDialog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ });
this._progress = 0L;
@@ -122,6 +134,20 @@ public class FileSplitterDialog extends javax.swing.JDialog {
_writePartToFile(i, remainingBytes, position * bytesPerSplit, sourceChannel, conta_split, numSplits + (remainingBytes > 0 ? 1 : 0));
}
}
+
+ while("".equals(_sha1)){
+ MiscTools.GUIRunAndWait(() -> {
+
+ split_button.setText("GENERATING SHA1, please wait...");
+
+ });
+
+ MiscTools.pausar(1000);
+ }
+
+ if(_sha1!=null){
+ Files.writeString(Paths.get(this._files[i].getAbsolutePath()+".sha1"), _sha1);
+ }
return true;
}
@@ -413,6 +439,8 @@ public class FileSplitterDialog extends javax.swing.JDialog {
this.jProgressBar2.setVisible(true);
pack();
+
+
Dialog tthis = this;
@@ -431,8 +459,8 @@ public class FileSplitterDialog extends javax.swing.JDialog {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().open(_output_dir);
- } catch (IOException ex) {
-
+ } catch (Exception ex) {
+ Logger.getLogger(FileSplitterDialog.class.getName()).log(Level.SEVERE, ex.getMessage());
}
}
@@ -475,7 +503,7 @@ public class FileSplitterDialog extends javax.swing.JDialog {
}
}
- } catch (IOException ex) {
+ } catch (Exception ex) {
Logger.getLogger(FileSplitterDialog.class.getName()).log(Level.SEVERE, ex.getMessage());
}
});
diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanel.java b/src/main/java/com/tonikelope/megabasterd/MainPanel.java
index 8db61969f..312868757 100644
--- a/src/main/java/com/tonikelope/megabasterd/MainPanel.java
+++ b/src/main/java/com/tonikelope/megabasterd/MainPanel.java
@@ -67,7 +67,7 @@ import javax.swing.UIManager;
*/
public final class MainPanel {
- public static final String VERSION = "7.70";
+ public static final String VERSION = "7.71";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
diff --git a/src/main/java/com/tonikelope/megabasterd/MiscTools.java b/src/main/java/com/tonikelope/megabasterd/MiscTools.java
index c0a0471e8..1e52c4601 100644
--- a/src/main/java/com/tonikelope/megabasterd/MiscTools.java
+++ b/src/main/java/com/tonikelope/megabasterd/MiscTools.java
@@ -27,9 +27,11 @@ import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -53,6 +55,7 @@ import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.CodeSource;
+import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
@@ -92,6 +95,7 @@ import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.xml.bind.DatatypeConverter;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
/**
*
@@ -124,6 +128,27 @@ public class MiscTools {
};
private static final Logger LOG = Logger.getLogger(MiscTools.class.getName());
+ public static String computeFileSHA1(File file) throws IOException {
+
+ try {
+ MessageDigest digest = MessageDigest.getInstance("SHA-1");
+ BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));
+ int n = 0;
+ byte[] buffer = new byte[8192];
+ while (n != -1) {
+ n = fis.read(buffer);
+ if (n > 0) {
+ digest.update(buffer, 0, n);
+ }
+ }
+ return new HexBinaryAdapter().marshal(digest.digest());
+ } catch (NoSuchAlgorithmException ex) {
+ Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ return null;
+ }
+
public static String getFechaHoraActual() {
String format = "dd-MM-yyyy HH:mm:ss";