Skip to content

Commit

Permalink
#647 FIX
Browse files Browse the repository at this point in the history
File split/merge sha1 removed
  • Loading branch information
tonikelope committed Aug 5, 2024
1 parent fc03de1 commit 53c65de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
34 changes: 6 additions & 28 deletions src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ 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;
Expand Down Expand Up @@ -86,17 +85,6 @@ public void keyReleased(java.awt.event.KeyEvent evt) {

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;

int mBperSplit = Integer.parseInt(this.split_size_text.getText());
Expand Down Expand Up @@ -135,20 +123,6 @@ private boolean _splitFile(int i) throws IOException {
}
}

while ("".equals(_sha1)) {
MiscTools.GUIRunAndWait(() -> {

split_button.setText(LabelTranslatorSingleton.getInstance().translate("GENERATING SHA1, please wait..."));

});

MiscTools.pausar(1000);
}

if (_sha1 != null) {
Files.writeString(Paths.get(this._files[i].getAbsolutePath() + ".sha1"), _sha1);
}

return true;
}

Expand Down Expand Up @@ -195,9 +169,13 @@ private void _writePartToFile(int f, long byteSize, long position, FileChannel s
monitorProgress(f, byteSize);

if (!_exit) {
long dest_bytes_copied = Files.exists(fileName) ? Files.size(fileName) : 0;

try (RandomAccessFile toFile = new RandomAccessFile(fileName.toFile(), "rw"); FileChannel toChannel = toFile.getChannel()) {
sourceChannel.position(position);
toChannel.transferFrom(sourceChannel, 0, byteSize);
while (dest_bytes_copied < byteSize) {
sourceChannel.position(position + dest_bytes_copied);
dest_bytes_copied += toChannel.transferFrom(sourceChannel, dest_bytes_copied, byteSize - dest_bytes_copied);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/tonikelope/megabasterd/MainPanelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ private void _new_upload_dialog(FileGrabberDialog dialog) {

if (dialog.getUpload_log_checkbox().isSelected()) {

MiscTools.createUploadLogDir();

File upload_log = new File(MiscTools.UPLOAD_LOGS_DIR + "/megabasterd_upload_" + parent_node + ".log");
upload_log.createNewFile();

Expand Down

0 comments on commit 53c65de

Please sign in to comment.