Folder cache for subfolders fix
This commit is contained in:
tonikelope 2023-10-26 03:35:19 +02:00
parent af6ee90df0
commit 1610b3b39d
7 changed files with 59 additions and 23 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId> <groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId> <artifactId>MegaBasterd</artifactId>
<version>8.6</version> <version>8.7</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<repositories> <repositories>
<repository> <repository>

View File

@ -56,6 +56,12 @@ public class FileGrabberDialog extends javax.swing.JDialog {
private int _last_selected_index; private int _last_selected_index;
private List<File> _drag_drop_files; private List<File> _drag_drop_files;
@Override
public void dispose() {
file_tree.setModel(null);
super.dispose();
}
public JCheckBox getPriority_checkbox() { public JCheckBox getPriority_checkbox() {
return priority_checkbox; return priority_checkbox;
} }

View File

@ -47,6 +47,12 @@ public class FolderLinkDialog extends javax.swing.JDialog {
private volatile boolean exit = false; private volatile boolean exit = false;
@Override
public void dispose() {
file_tree.setModel(null);
super.dispose();
}
public List<HashMap> getDownload_links() { public List<HashMap> getDownload_links() {
return Collections.unmodifiableList(_download_links); return Collections.unmodifiableList(_download_links);
} }
@ -430,6 +436,17 @@ public class FolderLinkDialog extends javax.swing.JDialog {
String folder_id = findFirstRegex("#F!([^!]+)", _link, 1); String folder_id = findFirstRegex("#F!([^!]+)", _link, 1);
String subfolder_id = null;
if (folder_id.contains("@")) {
String[] fids = folder_id.split("@");
folder_id = fids[0];
subfolder_id = fids[1];
}
int r = -1; int r = -1;
if (ma.existsCachedFolderNodes(folder_id)) { if (ma.existsCachedFolderNodes(folder_id)) {
@ -443,17 +460,6 @@ public class FolderLinkDialog extends javax.swing.JDialog {
}); });
} }
String subfolder_id = null;
if (folder_id.contains("@")) {
String[] fids = folder_id.split("@");
folder_id = fids[0];
subfolder_id = fids[1];
}
String folder_key = findFirstRegex("#F![^!]+!(.+)", _link, 1); String folder_key = findFirstRegex("#F![^!]+!(.+)", _link, 1);
folder_nodes = ma.getFolderNodes(folder_id, folder_key, node_bar, (r == 0)); folder_nodes = ma.getFolderNodes(folder_id, folder_key, node_bar, (r == 0));

View File

@ -70,7 +70,7 @@ import javax.swing.UIManager;
*/ */
public final class MainPanel { public final class MainPanel {
public static final String VERSION = "8.6"; public static final String VERSION = "8.7";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY 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 THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024; public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
@ -393,11 +393,6 @@ public final class MainPanel {
resumeUploads(); resumeUploads();
/* NOT REQUIRED
if (MegaAPI.API_KEY == null && JOptionPane.showConfirmDialog(this._view, LabelTranslatorSingleton.getInstance().translate("WARNING: USING MEGA API WITHOUT API KEY MAY VIOLATE ITS TERM OF USE.\n\nYOU SHOULD GET A KEY -> https://mega.nz/sdk (and set it in MegaBasterd ADVANCED SETTINGS).\n\nCREATE API KEY NOW?"), "MEGA API KEY ERROR", JOptionPane.ERROR_MESSAGE) == 0) {
openBrowserURL("https://mega.nz/sdk");
}*/
} }
public static Boolean getResume_uploads() { public static Boolean getResume_uploads() {

View File

@ -62,6 +62,12 @@ public final class MainPanelView extends javax.swing.JFrame {
private final MainPanel _main_panel; private final MainPanel _main_panel;
private static volatile MainPanelView INSTANCE = null;
public static MainPanelView getINSTANCE() {
return INSTANCE;
}
public JMenuItem getMerge_file_menu() { public JMenuItem getMerge_file_menu() {
return merge_file_menu; return merge_file_menu;
} }
@ -539,6 +545,7 @@ public final class MainPanelView extends javax.swing.JFrame {
pack(); pack();
}); });
INSTANCE = this;
} }
/** /**

View File

@ -39,6 +39,7 @@ import java.util.logging.Logger;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
/** /**
@ -1232,8 +1233,14 @@ public class MegaAPI implements Serializable {
String[] folder_parts = entry.getKey().split(":"); String[] folder_parts = entry.getKey().split(":");
int r = -1;
if (existsCachedFolderNodes(folder_parts[0])) {
r = JOptionPane.showConfirmDialog(MainPanelView.getINSTANCE(), "Do you want to use FOLDER [" + folder_parts[0] + "] CACHED VERSION?\n\n(It could speed up the loading of very large folders)", "FOLDER CACHE", JOptionPane.YES_NO_OPTION);
}
try { try {
nlinks.addAll(getNLinksFromFolder(folder_parts[0], folder_parts[1], entry.getValue())); nlinks.addAll(getNLinksFromFolder(folder_parts[0], folder_parts[1], entry.getValue(), (r == 0)));
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
} }
@ -1244,15 +1251,30 @@ public class MegaAPI implements Serializable {
} }
public ArrayList<String> getNLinksFromFolder(String folder_id, String folder_key, ArrayList<String> file_ids) throws Exception { public ArrayList<String> getNLinksFromFolder(String folder_id, String folder_key, ArrayList<String> file_ids, boolean cache) throws Exception {
ArrayList<String> nlinks = new ArrayList<>(); ArrayList<String> nlinks = new ArrayList<>();
String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\", \"ca\":\"1\"}]"; String res = null;
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&n=" + folder_id); if (cache) {
res = getCachedFolderNodes(folder_id);
}
String res = RAW_REQUEST(request, url_api); if (res == null) {
String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\", \"ca\":\"1\"}]";
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&n=" + folder_id);
res = RAW_REQUEST(request, url_api);
if (res != null) {
writeCachedFolderNodes(folder_id, res);
}
}
LOG.log(Level.INFO, "MEGA FOLDER {0} JSON FILE TREE SIZE -> {1}", new Object[]{folder_id, MiscTools.formatBytes((long) res.length())});
if (res != null) { if (res != null) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 209 KiB