mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-31 22:10:16 +02:00
2.06
-Mega API fatal error codes
This commit is contained in:
parent
fd66676587
commit
a3e4831bd7
@ -19,6 +19,7 @@ import java.security.InvalidKeyException;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import static java.util.concurrent.Executors.newCachedThreadPool;
|
import static java.util.concurrent.Executors.newCachedThreadPool;
|
||||||
@ -800,6 +801,8 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
if (!_provision_ok) {
|
if (!_provision_ok) {
|
||||||
|
|
||||||
|
_status_error = true;
|
||||||
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
if (_fatal_error != null) {
|
if (_fatal_error != null) {
|
||||||
@ -1192,7 +1195,10 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
error_code = parseInt(ex.getMessage());
|
error_code = parseInt(ex.getMessage());
|
||||||
|
|
||||||
|
if (Arrays.asList(FATAL_ERROR_API_CODES).contains(error_code)) {
|
||||||
|
|
||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
|
|
||||||
case -2:
|
case -2:
|
||||||
emergencyStopDownloader("Mega link is not valid! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("Mega link is not valid! " + MiscTools.truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
@ -1218,6 +1224,11 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
emergencyStopDownloader("MEGA/MC API FATAL ERROR: " + ex.getMessage() + " " + MiscTools.truncateText(link, 80));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
if (!retry_request) {
|
if (!retry_request) {
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ public final class DownloadManager extends TransferenceManager {
|
|||||||
|
|
||||||
getTransference_finished_queue().remove(d);
|
getTransference_finished_queue().remove(d);
|
||||||
|
|
||||||
_total_transferences_size -= d.getFile_size();
|
|
||||||
|
|
||||||
if (((Download) d).isProvision_ok()) {
|
if (((Download) d).isProvision_ok()) {
|
||||||
|
|
||||||
|
_total_transferences_size -= d.getFile_size();
|
||||||
|
|
||||||
delete_down.add(((Download) d).getUrl());
|
delete_down.add(((Download) d).getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "2.05";
|
public static final String VERSION = "2.06";
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
public static final int WATCHDOG_PORT = 1338;
|
public static final int WATCHDOG_PORT = 1338;
|
||||||
|
@ -38,6 +38,7 @@ public final class MegaAPI {
|
|||||||
public static final String API_URL = "https://g.api.mega.co.nz";
|
public static final String API_URL = "https://g.api.mega.co.nz";
|
||||||
public static final String API_KEY = null;
|
public static final String API_KEY = null;
|
||||||
public static final int REQ_ID_LENGTH = 10;
|
public static final int REQ_ID_LENGTH = 10;
|
||||||
|
public static final Integer[] MEGA_ERROR_EXCEPTION_CODES = {-2, -8, -9, -10, -11, -12, -13, -14, -15, -16};
|
||||||
|
|
||||||
public static int checkMEGAError(String data) {
|
public static int checkMEGAError(String data) {
|
||||||
String error = findFirstRegex("^\\[?(\\-[0-9]+)\\]?$", data, 1);
|
String error = findFirstRegex("^\\[?(\\-[0-9]+)\\]?$", data, 1);
|
||||||
@ -277,14 +278,12 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
|
|
||||||
boolean error;
|
int error, conta_error = 0;
|
||||||
|
|
||||||
int conta_error = 0;
|
|
||||||
|
|
||||||
HttpPost httppost;
|
HttpPost httppost;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
error = true;
|
error = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -318,9 +317,8 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
if (response.length() > 0) {
|
if (response.length() > 0) {
|
||||||
|
|
||||||
if (checkMEGAError(response) == 0) {
|
error = checkMEGAError(response);
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -332,9 +330,14 @@ public final class MegaAPI {
|
|||||||
Logger.getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error != 0) {
|
||||||
|
|
||||||
System.out.println("MegaAPI ERROR. Waiting for retry...");
|
if (Arrays.asList(MEGA_ERROR_EXCEPTION_CODES).contains(error)) {
|
||||||
|
|
||||||
|
throw new MegaAPIException(String.valueOf(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("MegaAPI ERROR " + String.valueOf(error) + " Waiting for retry...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(getWaitTimeExpBackOff(conta_error++) * 1000);
|
Thread.sleep(getWaitTimeExpBackOff(conta_error++) * 1000);
|
||||||
@ -347,8 +350,11 @@ public final class MegaAPI {
|
|||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (error);
|
} while (error != 0);
|
||||||
|
|
||||||
|
} catch (MegaAPIException | IOException exception) {
|
||||||
|
|
||||||
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
_seqno++;
|
_seqno++;
|
||||||
|
@ -13,7 +13,6 @@ import java.util.LinkedList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
import static megabasterd.MiscTools.BASE642Bin;
|
||||||
@ -22,7 +21,6 @@ import static megabasterd.MiscTools.Bin2UrlBASE64;
|
|||||||
import static megabasterd.MiscTools.cleanFilePath;
|
import static megabasterd.MiscTools.cleanFilePath;
|
||||||
import static megabasterd.MiscTools.cleanFilename;
|
import static megabasterd.MiscTools.cleanFilename;
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
import static megabasterd.MiscTools.findFirstRegex;
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
@ -44,16 +42,9 @@ public final class MegaCrypterAPI {
|
|||||||
String response = null;
|
String response = null;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
||||||
boolean error;
|
|
||||||
|
|
||||||
int conta_error = 0;
|
|
||||||
|
|
||||||
HttpPost httppost;
|
HttpPost httppost;
|
||||||
|
|
||||||
do {
|
|
||||||
|
|
||||||
error = true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httppost = new HttpPost(url_api.toURI());
|
httppost = new HttpPost(url_api.toURI());
|
||||||
|
|
||||||
@ -92,9 +83,6 @@ public final class MegaCrypterAPI {
|
|||||||
if ((mc_error = MegaCrypterAPI.checkMCError(response)) != 0) {
|
if ((mc_error = MegaCrypterAPI.checkMCError(response)) != 0) {
|
||||||
throw new MegaCrypterAPIException(String.valueOf(mc_error));
|
throw new MegaCrypterAPIException(String.valueOf(mc_error));
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
error = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,21 +93,6 @@ public final class MegaCrypterAPI {
|
|||||||
Logger.getLogger(MegaCrypterAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MegaCrypterAPI.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
|
||||||
|
|
||||||
System.out.println("MegaAPI ERROR. Waiting for retry...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(getWaitTimeExpBackOff(conta_error++) * 1000);
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
conta_error = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -15,6 +15,7 @@ public interface Transference {
|
|||||||
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
|
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
|
||||||
int MAX_TRANSFERENCE_SPEED_DEFAULT = 5;
|
int MAX_TRANSFERENCE_SPEED_DEFAULT = 5;
|
||||||
int MAX_WAIT_WORKERS_SHUTDOWN = 15;
|
int MAX_WAIT_WORKERS_SHUTDOWN = 15;
|
||||||
|
Integer[] FATAL_ERROR_API_CODES = {-2, -8, -9, -10, -11, -12, -13, -14, -15, -16, 22, 23, 24, 25};
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
@ -419,6 +419,8 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
if (!_provision_ok) {
|
if (!_provision_ok) {
|
||||||
|
|
||||||
|
_status_error = true;
|
||||||
|
|
||||||
getView().hideAllExceptStatus();
|
getView().hideAllExceptStatus();
|
||||||
|
|
||||||
if (_fatal_error != null) {
|
if (_fatal_error != null) {
|
||||||
|
@ -73,10 +73,10 @@ public final class UploadManager extends TransferenceManager {
|
|||||||
|
|
||||||
getTransference_finished_queue().remove(u);
|
getTransference_finished_queue().remove(u);
|
||||||
|
|
||||||
_total_transferences_size -= u.getFile_size();
|
|
||||||
|
|
||||||
if (((Upload) u).isProvision_ok()) {
|
if (((Upload) u).isProvision_ok()) {
|
||||||
|
|
||||||
|
_total_transferences_size -= u.getFile_size();
|
||||||
|
|
||||||
delete_up.add(new String[]{u.getFile_name(), ((Upload) u).getMa().getEmail()});
|
delete_up.add(new String[]{u.getFile_name(), ((Upload) u).getMa().getEmail()});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user