FileMerger fix
File Splitter SHA1
This commit is contained in:
tonikelope 2023-01-19 19:32:12 +01:00
parent 238bce81f1
commit 5eee0a2c69
6 changed files with 35 additions and 28 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId> <groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId> <artifactId>MegaBasterd</artifactId>
<version>7.71</version> <version>7.72</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<repositories> <repositories>
<repository> <repository>

View File

@ -132,17 +132,17 @@ public class FileMergerDialog extends javax.swing.JDialog {
if (Files.exists(Paths.get(_file_name_full + ".sha1"))) { if (Files.exists(Paths.get(_file_name_full + ".sha1"))) {
String sha1 = Files.readString(Paths.get(_file_name_full + ".sha1")).trim(); String sha1 = Files.readString(Paths.get(_file_name_full + ".sha1")).toLowerCase().trim();
MiscTools.GUIRunAndWait(() -> { MiscTools.GUIRunAndWait(() -> {
merge_button.setText("CHECKING FILE INTEGRITY, please wait..."); merge_button.setText(LabelTranslatorSingleton.getInstance().translate("CHECKING FILE INTEGRITY, please wait..."));
}); });
if (sha1.equals(MiscTools.computeFileSHA1(new File(_file_name_full)))) { if (sha1.equals(MiscTools.computeFileSHA1(new File(_file_name_full)))) {
JOptionPane.showMessageDialog(this, LabelTranslatorSingleton.getInstance().translate("FILE INTEGRITY OK")); JOptionPane.showMessageDialog(this, LabelTranslatorSingleton.getInstance().translate("FILE INTEGRITY IS OK"));
return true; return true;
} else { } else {
JOptionPane.showMessageDialog(this, LabelTranslatorSingleton.getInstance().translate("FILE SEEMS TO BE CORRUPTED"), "VERIFICATION ERROR", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, LabelTranslatorSingleton.getInstance().translate("FILE INTEGRITY CHECK FAILED"), "ERROR", JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
} }
@ -152,9 +152,15 @@ public class FileMergerDialog extends javax.swing.JDialog {
private void _deleteParts() { private void _deleteParts() {
try {
this._file_parts.stream().map((file_path) -> new File(file_path)).forEachOrdered((file) -> { this._file_parts.stream().map((file_path) -> new File(file_path)).forEachOrdered((file) -> {
file.delete(); file.delete();
}); });
Files.deleteIfExists(Paths.get(_file_name_full + ".sha1"));
} catch (IOException ex) {
Logger.getLogger(FileMergerDialog.class.getName()).log(Level.SEVERE, null, ex);
}
} }
/** /**

View File

@ -41,7 +41,7 @@ public class FileSplitterDialog extends javax.swing.JDialog {
private final MainPanel _main_panel; private final MainPanel _main_panel;
private File[] _files = null; private File[] _files = null;
private File _output_dir = null; private File _output_dir = null;
private volatile String _sha1=null; private volatile String _sha1 = null;
private volatile long _progress = 0L; private volatile long _progress = 0L;
private volatile Path _current_part = null; private volatile Path _current_part = null;
private volatile int _current_file = 0; private volatile int _current_file = 0;
@ -135,18 +135,18 @@ public class FileSplitterDialog extends javax.swing.JDialog {
} }
} }
while("".equals(_sha1)){ while ("".equals(_sha1)) {
MiscTools.GUIRunAndWait(() -> { MiscTools.GUIRunAndWait(() -> {
split_button.setText("GENERATING SHA1, please wait..."); split_button.setText(LabelTranslatorSingleton.getInstance().translate("GENERATING SHA1, please wait..."));
}); });
MiscTools.pausar(1000); MiscTools.pausar(1000);
} }
if(_sha1!=null){ if (_sha1 != null) {
Files.writeString(Paths.get(this._files[i].getAbsolutePath()+".sha1"), _sha1); Files.writeString(Paths.get(this._files[i].getAbsolutePath() + ".sha1"), _sha1);
} }
return true; return true;
@ -440,8 +440,6 @@ public class FileSplitterDialog extends javax.swing.JDialog {
pack(); pack();
Dialog tthis = this; Dialog tthis = this;
THREAD_POOL.execute(() -> { THREAD_POOL.execute(() -> {

View File

@ -1929,6 +1929,10 @@ public class LabelTranslatorSingleton {
} }
private void Spanish() { private void Spanish() {
_addTranslation("FILE INTEGRITY IS OK", "LA INTEGRIDAD DEL ARCHIVO ES CORRECTA");
_addTranslation("FILE INTEGRITY CHECK FAILED", "FALLÓ LA VERIFICACIÓN DE INTEGRIDAD DEL ARCHIVO");
_addTranslation("CHECKING FILE INTEGRITY, please wait...", "COMPROBANDO INTEGRIDAD DEL ARCHIVO, por favor espera...");
_addTranslation("GENERATING SHA1, please wait...", "GENERANDO SHA1, por favor espera...");
_addTranslation("COPY ALL", "COPIAR TODO"); _addTranslation("COPY ALL", "COPIAR TODO");
_addTranslation("ALL COPIED!", "¡TODO COPIADO!"); _addTranslation("ALL COPIED!", "¡TODO COPIADO!");
_addTranslation("FILE WITH SAME NAME AND SIZE ALREADY EXISTS", "YA EXISTE UN FICHERO CON EL MISMO NOMBRE Y TAMAÑO"); _addTranslation("FILE WITH SAME NAME AND SIZE ALREADY EXISTS", "YA EXISTE UN FICHERO CON EL MISMO NOMBRE Y TAMAÑO");

View File

@ -67,7 +67,7 @@ import javax.swing.UIManager;
*/ */
public final class MainPanel { public final class MainPanel {
public static final String VERSION = "7.71"; public static final String VERSION = "7.72";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY 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 THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024; public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;

View File

@ -55,7 +55,6 @@ import java.nio.file.LinkOption;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.security.CodeSource; import java.security.CodeSource;
import java.security.DigestInputStream;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.DateFormat; import java.text.DateFormat;
@ -141,7 +140,7 @@ public class MiscTools {
digest.update(buffer, 0, n); digest.update(buffer, 0, n);
} }
} }
return new HexBinaryAdapter().marshal(digest.digest()); return new HexBinaryAdapter().marshal(digest.digest()).toLowerCase().trim();
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
} }