Skip to content

Commit

Permalink
7.38
Browse files Browse the repository at this point in the history
Trying to fix -> #282
  • Loading branch information
tonikelope committed Jan 4, 2021
1 parent 71427a2 commit 5847ff5
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>7.37</version>
<version>7.38</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(Level.SEVERE, ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(Level.SEVERE, ex.getMessage());
Expand Down
96 changes: 50 additions & 46 deletions src/main/java/com/tonikelope/megabasterd/ChunkWriterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(Level.SEVERE, ex.getMessage());
Expand Down Expand Up @@ -153,77 +153,81 @@ public void delete_chunks_temp_dir() {
@Override
public void run() {

try {
LOG.log(Level.INFO, "{0} ChunkWriterManager: let's do some work! {1}", new Object[]{Thread.currentThread().getName(), _download.getFile_name()});
LOG.log(Level.INFO, "{0} ChunkWriterManager LAST CHUNK WRITTEN -> [{1}] {2} {3}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written, _bytes_written, _download.getFile_name()});
boolean download_finished = false;
if (_file_size > 0) {
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {

LOG.log(Level.INFO, "{0} ChunkWriterManager: let's do some work! {1}", new Object[]{Thread.currentThread().getName(), _download.getFile_name()});
boolean chunk_io_error;

LOG.log(Level.INFO, "{0} ChunkWriterManager LAST CHUNK WRITTEN -> [{1}] {2} {3}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written, _bytes_written, _download.getFile_name()});
do {

boolean download_finished = false;
chunk_io_error = false;

if (_file_size > 0) {
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
try {

File chunk_file = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1));
File chunk_file = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1));

while (chunk_file.exists() && chunk_file.canRead()) {
while (chunk_file.exists() && chunk_file.canRead() && chunk_file.length() > 0) {

if (!download_finished && _download.getProgress() == _file_size) {
if (!download_finished && _download.getProgress() == _file_size) {

_download.getMain_panel().getDownload_manager().getTransference_running_list().remove(_download);
_download.getMain_panel().getDownload_manager().secureNotify();
_download.getMain_panel().getDownload_manager().getTransference_running_list().remove(_download);
_download.getMain_panel().getDownload_manager().secureNotify();

_download.getView().printStatusNormal("Download finished. Joining file chunks, please wait...");
_download.getView().getPause_button().setVisible(false);
_download.getMain_panel().getGlobal_dl_speed().detachTransference(_download);
_download.getView().getSpeed_label().setVisible(false);
_download.getView().getSlots_label().setVisible(false);
_download.getView().getSlot_status_label().setVisible(false);
_download.getView().getSlots_spinner().setVisible(false);
download_finished = true;
}
_download.getView().printStatusNormal("Download finished. Joining file chunks, please wait...");
_download.getView().getPause_button().setVisible(false);
_download.getMain_panel().getGlobal_dl_speed().detachTransference(_download);
_download.getView().getSpeed_label().setVisible(false);
_download.getView().getSlots_label().setVisible(false);
_download.getView().getSlot_status_label().setVisible(false);
_download.getView().getSlots_spinner().setVisible(false);
download_finished = true;
}

byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE];
byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE];

int reads;
int reads;

try (CipherInputStream cis = new CipherInputStream(new BufferedInputStream(new FileInputStream(chunk_file)), genDecrypter("AES", "AES/CTR/NoPadding", _byte_file_key, forwardMEGALinkKeyIV(_byte_iv, _bytes_written)))) {
while ((reads = cis.read(buffer)) != -1) {
_download.getOutput_stream().write(buffer, 0, reads);
try (CipherInputStream cis = new CipherInputStream(new BufferedInputStream(new FileInputStream(chunk_file)), genDecrypter("AES", "AES/CTR/NoPadding", _byte_file_key, forwardMEGALinkKeyIV(_byte_iv, _bytes_written)))) {
while ((reads = cis.read(buffer)) != -1) {
_download.getOutput_stream().write(buffer, 0, reads);
}
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}

_bytes_written += chunk_file.length();
_bytes_written += chunk_file.length();

LOG.log(Level.INFO, "{0} ChunkWriterManager has written to disk chunk [{1}] {2} {3} {4}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1, _bytes_written, _download.calculateLastWrittenChunk(_bytes_written), _download.getFile_name()});
_last_chunk_id_written++;

_last_chunk_id_written++;
LOG.log(Level.INFO, "{0} ChunkWriterManager has written to disk chunk [{1}] {2} {3} {4}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written, _bytes_written, _download.calculateLastWrittenChunk(_bytes_written), _download.getFile_name()});

chunk_file.delete();
chunk_file.delete();

chunk_file = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1));
}
chunk_file = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1));

if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
}
} catch (IOException ex) {
chunk_io_error = true;
LOG.log(Level.WARNING, ex.getMessage());
MiscTools.pausar(1000);
}
} while (chunk_io_error);

LOG.log(Level.INFO, "{0} ChunkWriterManager waiting for chunk [{1}] {2}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1, _download.getFile_name()});
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {

secureWait();
LOG.log(Level.INFO, "{0} ChunkWriterManager waiting for chunk [{1}] {2}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1, _download.getFile_name()});

}
}
secureWait();

if (_bytes_written == _file_size) {
delete_chunks_temp_dir();
}
}

} catch (IOException ex) {

LOG.log(Level.SEVERE, ex.getMessage());
_download.stopDownloader(ex.getMessage());
if (_bytes_written == _file_size) {
delete_chunks_temp_dir();
}
}

_exit = true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/ClipboardSpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
LOG.log(SEVERE, ex.getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(SEVERE, null, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
LOG.log(SEVERE, null, ex);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*/
public final class MainPanel {

public static final String VERSION = "7.37";
public static final String VERSION = "7.38";
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(SEVERE, null, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void secureWait() {
while (!_notified_threads.get(current_thread)) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void secureWait() {
while (!_notified_threads.get(current_thread)) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
LOG.log(Level.SEVERE, ex.getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/Upload.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(Level.SEVERE, ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void secureWait() {
while (!_notified) {

try {
_secure_notify_lock.wait();
_secure_notify_lock.wait(1000);
} catch (InterruptedException ex) {
_exit = true;
LOG.log(Level.SEVERE, ex.getMessage());
Expand Down
Binary file modified src/main/resources/images/mbasterd_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5847ff5

Please sign in to comment.