diff --git a/pom.xml b/pom.xml index 447a6a967..40f436f26 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.tonikelope MegaBasterd - 7.37 + 7.38 jar diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java b/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java index 4a97bdb35..26e936239 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java @@ -97,7 +97,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(Level.SEVERE, ex.getMessage()); diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java b/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java index cbff66f3b..b3f9f3a6e 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java @@ -72,7 +72,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable { while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(Level.SEVERE, ex.getMessage()); diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkWriterManager.java b/src/main/java/com/tonikelope/megabasterd/ChunkWriterManager.java index a872bad65..d2107cc48 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkWriterManager.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkWriterManager.java @@ -113,7 +113,7 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(Level.SEVERE, ex.getMessage()); @@ -153,77 +153,81 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl @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; - } - - byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE]; - - 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); + _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; } - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) { - LOG.log(Level.SEVERE, ex.getMessage()); + + byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE]; + + 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); + } + } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) { + LOG.log(Level.SEVERE, ex.getMessage()); + } + + _bytes_written += chunk_file.length(); + + _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 = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1)); + } - - _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++; - - chunk_file.delete(); - - chunk_file = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1)); + } catch (IOException ex) { + chunk_io_error = true; + LOG.log(Level.WARNING, ex.getMessage()); + MiscTools.pausar(1000); } + } while (chunk_io_error); - if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) { + if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) { - LOG.log(Level.INFO, "{0} ChunkWriterManager waiting for chunk [{1}] {2}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1, _download.getFile_name()}); + 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(); + 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; diff --git a/src/main/java/com/tonikelope/megabasterd/ClipboardSpy.java b/src/main/java/com/tonikelope/megabasterd/ClipboardSpy.java index 4c32ed9d1..4fe36f77a 100644 --- a/src/main/java/com/tonikelope/megabasterd/ClipboardSpy.java +++ b/src/main/java/com/tonikelope/megabasterd/ClipboardSpy.java @@ -81,7 +81,7 @@ public class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingleThrea while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { LOG.log(SEVERE, ex.getMessage()); } diff --git a/src/main/java/com/tonikelope/megabasterd/Download.java b/src/main/java/com/tonikelope/megabasterd/Download.java index 48287a3ca..c98013aa0 100644 --- a/src/main/java/com/tonikelope/megabasterd/Download.java +++ b/src/main/java/com/tonikelope/megabasterd/Download.java @@ -1621,7 +1621,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(SEVERE, null, ex); diff --git a/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java b/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java index 4bca3c2e6..b13b37e81 100644 --- a/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java +++ b/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java @@ -87,7 +87,7 @@ public class KissVideoStreamServer implements HttpHandler, SecureSingleThreadNot while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { LOG.log(SEVERE, null, ex); } diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanel.java b/src/main/java/com/tonikelope/megabasterd/MainPanel.java index d9d4d6063..e13a79583 100644 --- a/src/main/java/com/tonikelope/megabasterd/MainPanel.java +++ b/src/main/java/com/tonikelope/megabasterd/MainPanel.java @@ -60,7 +60,7 @@ import javax.swing.UIManager; */ 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; diff --git a/src/main/java/com/tonikelope/megabasterd/ProgressMeter.java b/src/main/java/com/tonikelope/megabasterd/ProgressMeter.java index 957812911..68fa212d0 100644 --- a/src/main/java/com/tonikelope/megabasterd/ProgressMeter.java +++ b/src/main/java/com/tonikelope/megabasterd/ProgressMeter.java @@ -47,7 +47,7 @@ public class ProgressMeter implements Runnable, SecureSingleThreadNotifiable { while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(SEVERE, null, ex); diff --git a/src/main/java/com/tonikelope/megabasterd/StreamChunkManager.java b/src/main/java/com/tonikelope/megabasterd/StreamChunkManager.java index d3b927561..ac3b8e296 100644 --- a/src/main/java/com/tonikelope/megabasterd/StreamChunkManager.java +++ b/src/main/java/com/tonikelope/megabasterd/StreamChunkManager.java @@ -170,7 +170,7 @@ public class StreamChunkManager implements Runnable, SecureMultiThreadNotifiable 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()); } diff --git a/src/main/java/com/tonikelope/megabasterd/StreamThrottlerSupervisor.java b/src/main/java/com/tonikelope/megabasterd/StreamThrottlerSupervisor.java index 89ae47772..0aee31ed5 100644 --- a/src/main/java/com/tonikelope/megabasterd/StreamThrottlerSupervisor.java +++ b/src/main/java/com/tonikelope/megabasterd/StreamThrottlerSupervisor.java @@ -96,7 +96,7 @@ public class StreamThrottlerSupervisor implements Runnable, SecureMultiThreadNot 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()); } diff --git a/src/main/java/com/tonikelope/megabasterd/TransferenceManager.java b/src/main/java/com/tonikelope/megabasterd/TransferenceManager.java index 8c9f693de..b9e5473e1 100644 --- a/src/main/java/com/tonikelope/megabasterd/TransferenceManager.java +++ b/src/main/java/com/tonikelope/megabasterd/TransferenceManager.java @@ -212,7 +212,7 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { LOG.log(Level.SEVERE, ex.getMessage()); } diff --git a/src/main/java/com/tonikelope/megabasterd/Upload.java b/src/main/java/com/tonikelope/megabasterd/Upload.java index ebd2eee3f..fbb7879f9 100644 --- a/src/main/java/com/tonikelope/megabasterd/Upload.java +++ b/src/main/java/com/tonikelope/megabasterd/Upload.java @@ -360,7 +360,7 @@ public class Upload implements Transference, Runnable, SecureSingleThreadNotifia while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(Level.SEVERE, ex.getMessage()); diff --git a/src/main/java/com/tonikelope/megabasterd/UploadMACGenerator.java b/src/main/java/com/tonikelope/megabasterd/UploadMACGenerator.java index 83aa76c5f..8512a9657 100644 --- a/src/main/java/com/tonikelope/megabasterd/UploadMACGenerator.java +++ b/src/main/java/com/tonikelope/megabasterd/UploadMACGenerator.java @@ -49,7 +49,7 @@ public class UploadMACGenerator implements Runnable, SecureSingleThreadNotifiabl while (!_notified) { try { - _secure_notify_lock.wait(); + _secure_notify_lock.wait(1000); } catch (InterruptedException ex) { _exit = true; LOG.log(Level.SEVERE, ex.getMessage()); diff --git a/src/main/resources/images/mbasterd_screen.png b/src/main/resources/images/mbasterd_screen.png index 8a25f7e1b..268f178f3 100644 Binary files a/src/main/resources/images/mbasterd_screen.png and b/src/main/resources/images/mbasterd_screen.png differ