Skip to content

Commit

Permalink
8.16
Browse files Browse the repository at this point in the history
Upload logs in folder
SmartProxy tunning
  • Loading branch information
tonikelope committed Dec 4, 2023
1 parent 3c327bc commit 8ce5b11
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 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>8.15</version>
<version>8.16</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,15 @@ public void run() {

if (_current_smart_proxy != null && chunk_error) {

proxy_manager.blockProxy(_current_smart_proxy, timeout ? "TIMEOUT!" : "HTTP " + String.valueOf(http_error));
if (!timeout && http_error != 429) {
proxy_manager.blockProxy(_current_smart_proxy, timeout ? "TIMEOUT!" : "HTTP " + String.valueOf(http_error));
} else if (timeout) {
_excluded_proxy_list.add(_current_smart_proxy);
LOG.log(Level.WARNING, "{0} Worker [{1}] PROXY {2} TIMEOUT", new Object[]{Thread.currentThread().getName(), _id, _current_smart_proxy});
} else {
_excluded_proxy_list.add(_current_smart_proxy);
LOG.log(Level.WARNING, "{0} Worker [{1}] PROXY {2} TOO MANY CONNECTIONS", new Object[]{Thread.currentThread().getName(), _id, _current_smart_proxy});
}

String[] smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);

Expand Down Expand Up @@ -274,6 +282,8 @@ public void run() {

timeout = false;

http_error = 0;

File tmp_chunk_file = null, chunk_file = null;

LOG.log(Level.INFO, "{0} Worker [{1}] is downloading chunk [{2}]! {3}", new Object[]{Thread.currentThread().getName(), _id, chunk_id, _download.getFile_name()});
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/tonikelope/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
public final class MainPanel {

public static final String VERSION = "8.15";
public static final String VERSION = "8.16";
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 Expand Up @@ -256,6 +256,8 @@ public MainPanel() {

_resume_downloads = false;

MiscTools.createUploadLogDir();

try {

setupSqliteTables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void _new_upload_dialog(FileGrabberDialog dialog) {

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

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

FileWriter fr;
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/tonikelope/megabasterd/MiscTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public class MiscTools {
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 8;
public static final Object PASS_LOCK = new Object();
public static final int HTTP_TIMEOUT = 30;
public static final String UPLOAD_LOGS_DIR = System.getProperty("user.home") + File.separator + "MEGABASTERD_UPLOAD_LOGS";

private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = (DefaultMutableTreeNode a, DefaultMutableTreeNode b) -> {
if (a.isLeaf() && !b.isLeaf()) {
return 1;
Expand Down Expand Up @@ -160,6 +162,27 @@ public static String computeFileSHA1(File file) throws IOException {
return null;
}

public static void createUploadLogDir() {

if (!Files.exists(Paths.get(UPLOAD_LOGS_DIR))) {
try {
Files.createDirectory(Paths.get(UPLOAD_LOGS_DIR));

File dir = new File(System.getProperty("user.home"));

for (File file : dir.listFiles()) {
if (!file.isDirectory() && file.getName().startsWith("megabasterd_upload_")) {
Files.move(file.toPath(), Paths.get(UPLOAD_LOGS_DIR + File.separator + file.getName()));
}
}

} catch (IOException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
}

}
}

public static void purgeFolderCache() {
File directory = new File(System.getProperty("java.io.tmpdir"));

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 @@ -992,7 +992,7 @@ public void run() {

synchronized (this.getMain_panel().getUpload_manager().getLog_file_lock()) {

File upload_log = new File(MainPanel.MEGABASTERD_HOME_DIR + "/megabasterd_upload_" + _root_node + ".log");
File upload_log = new File(MiscTools.UPLOAD_LOGS_DIR + "/megabasterd_upload_" + _root_node + ".log");

if (upload_log.exists()) {

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 8ce5b11

Please sign in to comment.