mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-04-29 22:24:32 +02:00
7.52
VERY VERY VERY BIG FOLDERS PERFORMANCE FIX https://github.com/tonikelope/megabasterd/issues/416
This commit is contained in:
parent
e96925f9ed
commit
f5cf9001b1
6
pom.xml
6
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>7.51</version>
|
||||
<version>7.52</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -15,13 +15,13 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.6</version>
|
||||
<version>2.12.6</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.9</version>
|
||||
<version>2.12.6</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -24,11 +24,12 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="link_detected_label" max="32767" attributes="0"/>
|
||||
<Component id="file_tree_scrollpane" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="node_bar" max="32767" attributes="0"/>
|
||||
<Component id="link_detected_label" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="file_tree_scrollpane" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="total_space_label" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="warning_label" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
@ -52,25 +53,24 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="skip_rest_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="skip_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="dance_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="link_detected_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="folder_link_label" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="restore_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="file_tree_scrollpane" pref="295" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="node_bar" min="-2" pref="14" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
|
||||
<Component id="skip_rest_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="skip_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="dance_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="link_detected_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="folder_link_label" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="restore_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="file_tree_scrollpane" pref="315" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="total_space_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="warning_label" min="-2" max="-2" attributes="0"/>
|
||||
@ -214,5 +214,7 @@
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JProgressBar" name="node_bar">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -72,6 +72,8 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
|
||||
translateLabels(this);
|
||||
|
||||
node_bar.setIndeterminate(true);
|
||||
|
||||
folder_link_label.setText(link);
|
||||
|
||||
restore_button.setVisible(false);
|
||||
@ -133,6 +135,7 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
skip_rest_button = new javax.swing.JButton();
|
||||
restore_button = new javax.swing.JButton();
|
||||
total_space_label = new javax.swing.JLabel();
|
||||
node_bar = new javax.swing.JProgressBar();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("FolderLink");
|
||||
@ -211,20 +214,21 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(link_detected_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(file_tree_scrollpane)
|
||||
.addComponent(total_space_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(warning_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(node_bar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(link_detected_label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(total_space_label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(warning_label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(skip_rest_button)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(skip_button)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(dance_button))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(folder_link_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(restore_button)))
|
||||
@ -234,22 +238,22 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(skip_rest_button)
|
||||
.addComponent(skip_button)
|
||||
.addComponent(dance_button)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(link_detected_label)
|
||||
.addGap(8, 8, 8)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(folder_link_label)
|
||||
.addComponent(restore_button))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(link_detected_label)
|
||||
.addGap(8, 8, 8)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(folder_link_label)
|
||||
.addComponent(restore_button))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(node_bar, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(skip_rest_button)
|
||||
.addComponent(skip_button)
|
||||
.addComponent(dance_button))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(total_space_label)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(warning_label)
|
||||
@ -263,18 +267,24 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
private void skip_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_buttonActionPerformed
|
||||
|
||||
if (deleteSelectedTreeItems(file_tree)) {
|
||||
node_bar.setVisible(true);
|
||||
skip_rest_button.setEnabled(false);
|
||||
skip_button.setEnabled(false);
|
||||
THREAD_POOL.execute(() -> {
|
||||
|
||||
_genDownloadLiks();
|
||||
_genDownloadLiks();
|
||||
MiscTools.GUIRun(() -> {
|
||||
restore_button.setVisible(true);
|
||||
|
||||
restore_button.setVisible(true);
|
||||
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||
|
||||
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||
dance_button.setEnabled(root_childs);
|
||||
|
||||
dance_button.setEnabled(root_childs);
|
||||
skip_button.setEnabled(root_childs);
|
||||
|
||||
skip_button.setEnabled(root_childs);
|
||||
|
||||
skip_rest_button.setEnabled(root_childs);
|
||||
skip_rest_button.setEnabled(root_childs);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -290,18 +300,23 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
private void skip_rest_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_rest_buttonActionPerformed
|
||||
|
||||
if (deleteAllExceptSelectedTreeItems(file_tree)) {
|
||||
node_bar.setVisible(true);
|
||||
skip_rest_button.setEnabled(false);
|
||||
skip_button.setEnabled(false);
|
||||
THREAD_POOL.execute(() -> {
|
||||
_genDownloadLiks();
|
||||
MiscTools.GUIRun(() -> {
|
||||
restore_button.setVisible(true);
|
||||
|
||||
_genDownloadLiks();
|
||||
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||
|
||||
restore_button.setVisible(true);
|
||||
dance_button.setEnabled(root_childs);
|
||||
|
||||
boolean root_childs = ((TreeNode) file_tree.getModel().getRoot()).getChildCount() > 0;
|
||||
skip_button.setEnabled(root_childs);
|
||||
|
||||
dance_button.setEnabled(root_childs);
|
||||
|
||||
skip_button.setEnabled(root_childs);
|
||||
|
||||
skip_rest_button.setEnabled(root_childs);
|
||||
skip_rest_button.setEnabled(root_childs);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_skip_rest_buttonActionPerformed
|
||||
@ -316,6 +331,10 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
|
||||
dance_button.setEnabled(false);
|
||||
|
||||
node_bar.setVisible(true);
|
||||
|
||||
node_bar.setIndeterminate(true);
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
_loadMegaDirTree();
|
||||
_genDownloadLiks();
|
||||
@ -348,12 +367,30 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
|
||||
String folder_key = findFirstRegex("#F![^!]+!(.+)", _link, 1);
|
||||
|
||||
folder_nodes = ma.getFolderNodes(folder_id, folder_key);
|
||||
folder_nodes = ma.getFolderNodes(folder_id, folder_key, node_bar);
|
||||
|
||||
MegaMutableTreeNode root = null;
|
||||
|
||||
final int nodos_totales = folder_nodes.size();
|
||||
|
||||
MiscTools.GUIRun(() -> {
|
||||
node_bar.setIndeterminate(false);
|
||||
node_bar.setMaximum(nodos_totales);
|
||||
node_bar.setValue(0);
|
||||
});
|
||||
|
||||
int conta_nodo = 0;
|
||||
|
||||
for (Object o : folder_nodes.values()) {
|
||||
|
||||
conta_nodo++;
|
||||
|
||||
int c = conta_nodo;
|
||||
MiscTools.GUIRun(() -> {
|
||||
|
||||
node_bar.setValue(c);
|
||||
});
|
||||
|
||||
HashMap<String, Object> current_hashmap_node = (HashMap<String, Object>) o;
|
||||
|
||||
MegaMutableTreeNode current_node;
|
||||
@ -406,6 +443,15 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
} while (current_node != root);
|
||||
}
|
||||
|
||||
MiscTools.GUIRun(() -> {
|
||||
|
||||
node_bar.setIndeterminate(true);
|
||||
});
|
||||
|
||||
MiscTools.sortTree(root);
|
||||
|
||||
MiscTools.calculateTreeFolderSizes(root);
|
||||
|
||||
if (root == null) {
|
||||
LOG.log(SEVERE, null, "MEGA FOLDER ERROR (EMPTY?)");
|
||||
|
||||
@ -417,7 +463,10 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
final MegaMutableTreeNode roott = root;
|
||||
|
||||
MiscTools.GUIRun(() -> {
|
||||
ftree.setModel(new DefaultTreeModel(sortTree(roott)));
|
||||
|
||||
node_bar.setIndeterminate(true);
|
||||
|
||||
ftree.setModel(new DefaultTreeModel(roott));
|
||||
|
||||
ftree.setRootVisible(roott != null ? roott.getChildCount() > 0 : false);
|
||||
|
||||
@ -447,74 +496,77 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
|
||||
private void _genDownloadLiks() {
|
||||
|
||||
MiscTools.GUIRunAndWait(() -> {
|
||||
MiscTools.GUIRun(() -> {
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
});
|
||||
|
||||
String folder_id = findFirstRegex("#F!([^!]+)", _link, 1);
|
||||
String folder_id = findFirstRegex("#F!([^!]+)", _link, 1);
|
||||
|
||||
_download_links.clear();
|
||||
_download_links.clear();
|
||||
|
||||
MegaMutableTreeNode root = (MegaMutableTreeNode) file_tree.getModel().getRoot();
|
||||
MegaMutableTreeNode root = (MegaMutableTreeNode) file_tree.getModel().getRoot();
|
||||
|
||||
Enumeration files_tree = root.depthFirstEnumeration();
|
||||
Enumeration files_tree = root.depthFirstEnumeration();
|
||||
|
||||
_total_space = 0L;
|
||||
_total_space = 0L;
|
||||
|
||||
while (files_tree.hasMoreElements()) {
|
||||
while (files_tree.hasMoreElements()) {
|
||||
|
||||
MegaMutableTreeNode node = (MegaMutableTreeNode) files_tree.nextElement();
|
||||
MegaMutableTreeNode node = (MegaMutableTreeNode) files_tree.nextElement();
|
||||
|
||||
if (node.isLeaf() && node != root && ((HashMap<String, Object>) node.getUserObject()).get("size") != null) {
|
||||
if (node.isLeaf() && node != root && ((HashMap<String, Object>) node.getUserObject()).get("size") != null) {
|
||||
|
||||
String path = "";
|
||||
String path = "";
|
||||
|
||||
Object[] object_path = node.getUserObjectPath();
|
||||
Object[] object_path = node.getUserObjectPath();
|
||||
|
||||
for (Object p : object_path) {
|
||||
for (Object p : object_path) {
|
||||
|
||||
path += File.separator + ((Map<String, Object>) p).get("name");
|
||||
}
|
||||
|
||||
path = path.replaceAll("^/+", "").replaceAll("^\\+", "").trim();
|
||||
|
||||
String url = "https://mega.nz/#N!" + ((Map<String, Object>) node.getUserObject()).get("h") + "!" + ((Map<String, Object>) node.getUserObject()).get("key") + "###n=" + folder_id;
|
||||
|
||||
HashMap<String, Object> download_link = new HashMap<>();
|
||||
|
||||
download_link.put("url", url);
|
||||
|
||||
download_link.put("filename", cleanFilePath(path));
|
||||
|
||||
download_link.put("filekey", ((Map<String, Object>) node.getUserObject()).get("key"));
|
||||
|
||||
download_link.put("filesize", ((Map<String, Object>) node.getUserObject()).get("size"));
|
||||
|
||||
_total_space += (long) download_link.get("filesize");
|
||||
|
||||
_download_links.add(download_link);
|
||||
} else if (node.isLeaf() && node != root) {
|
||||
String path = "";
|
||||
|
||||
Object[] object_path = node.getUserObjectPath();
|
||||
|
||||
for (Object p : object_path) {
|
||||
|
||||
path += File.separator + ((Map<String, Object>) p).get("name");
|
||||
}
|
||||
|
||||
path = path.replaceAll("^/+", "").replaceAll("^\\+", "").trim();
|
||||
|
||||
HashMap<String, Object> download_link = new HashMap<>();
|
||||
|
||||
download_link.put("url", "*");
|
||||
|
||||
download_link.put("filename", cleanFilePath(path));
|
||||
|
||||
download_link.put("type", ((HashMap<String, Object>) node.getUserObject()).get("type"));
|
||||
|
||||
_download_links.add(download_link);
|
||||
path += File.separator + ((Map<String, Object>) p).get("name");
|
||||
}
|
||||
|
||||
path = path.replaceAll("^/+", "").replaceAll("^\\+", "").trim();
|
||||
|
||||
String url = "https://mega.nz/#N!" + ((Map<String, Object>) node.getUserObject()).get("h") + "!" + ((Map<String, Object>) node.getUserObject()).get("key") + "###n=" + folder_id;
|
||||
|
||||
HashMap<String, Object> download_link = new HashMap<>();
|
||||
|
||||
download_link.put("url", url);
|
||||
|
||||
download_link.put("filename", cleanFilePath(path));
|
||||
|
||||
download_link.put("filekey", ((Map<String, Object>) node.getUserObject()).get("key"));
|
||||
|
||||
download_link.put("filesize", ((Map<String, Object>) node.getUserObject()).get("size"));
|
||||
|
||||
_total_space += (long) download_link.get("filesize");
|
||||
|
||||
_download_links.add(download_link);
|
||||
} else if (node.isLeaf() && node != root) {
|
||||
String path = "";
|
||||
|
||||
Object[] object_path = node.getUserObjectPath();
|
||||
|
||||
for (Object p : object_path) {
|
||||
|
||||
path += File.separator + ((Map<String, Object>) p).get("name");
|
||||
}
|
||||
|
||||
path = path.replaceAll("^/+", "").replaceAll("^\\+", "").trim();
|
||||
|
||||
HashMap<String, Object> download_link = new HashMap<>();
|
||||
|
||||
download_link.put("url", "*");
|
||||
|
||||
download_link.put("filename", cleanFilePath(path));
|
||||
|
||||
download_link.put("type", ((HashMap<String, Object>) node.getUserObject()).get("type"));
|
||||
|
||||
_download_links.add(download_link);
|
||||
}
|
||||
}
|
||||
|
||||
MiscTools.GUIRun(() -> {
|
||||
|
||||
total_space_label.setText("[" + formatBytes(_total_space) + "]");
|
||||
|
||||
@ -523,6 +575,8 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
c.setEnabled(root.getChildCount() > 0);
|
||||
}
|
||||
|
||||
node_bar.setVisible(false);
|
||||
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
});
|
||||
}
|
||||
@ -533,6 +587,7 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JScrollPane file_tree_scrollpane;
|
||||
private javax.swing.JLabel folder_link_label;
|
||||
private javax.swing.JLabel link_detected_label;
|
||||
private javax.swing.JProgressBar node_bar;
|
||||
private javax.swing.JButton restore_button;
|
||||
private javax.swing.JButton skip_button;
|
||||
private javax.swing.JButton skip_rest_button;
|
||||
|
@ -58,7 +58,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "7.51";
|
||||
public static final String VERSION = "7.52";
|
||||
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;
|
||||
|
@ -25,6 +25,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.swing.JProgressBar;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -932,7 +933,7 @@ public class MegaAPI implements Serializable {
|
||||
return ch;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getFolderNodes(String folder_id, String folder_key) throws Exception {
|
||||
public HashMap<String, Object> getFolderNodes(String folder_id, String folder_key, JProgressBar bar) throws Exception {
|
||||
|
||||
HashMap<String, Object> folder_nodes = null;
|
||||
|
||||
@ -950,8 +951,27 @@ public class MegaAPI implements Serializable {
|
||||
|
||||
folder_nodes = new HashMap<>();
|
||||
|
||||
int s = ((List) res_map[0].get("f")).size();
|
||||
|
||||
MiscTools.GUIRun(() -> {
|
||||
bar.setIndeterminate(false);
|
||||
bar.setMaximum(s);
|
||||
bar.setValue(0);
|
||||
});
|
||||
|
||||
int conta_nodo = 0;
|
||||
|
||||
for (Object o : (Iterable<? extends Object>) res_map[0].get("f")) {
|
||||
|
||||
conta_nodo++;
|
||||
|
||||
int c = conta_nodo;
|
||||
|
||||
MiscTools.GUIRun(() -> {
|
||||
|
||||
bar.setValue(c);
|
||||
});
|
||||
|
||||
HashMap<String, Object> node = (HashMap<String, Object>) o;
|
||||
|
||||
String[] node_k = ((String) node.get("k")).split(":");
|
||||
@ -984,6 +1004,8 @@ public class MegaAPI implements Serializable {
|
||||
long size = (Long) node.get("s");
|
||||
the_node.put("size", size);
|
||||
}
|
||||
} else {
|
||||
the_node.put("size", 0L);
|
||||
}
|
||||
|
||||
the_node.put("name", at.get("n"));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.tonikelope.megabasterd;
|
||||
|
||||
import static com.tonikelope.megabasterd.MiscTools.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
@ -15,6 +14,9 @@ import javax.swing.tree.MutableTreeNode;
|
||||
public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(MegaMutableTreeNode.class.getName());
|
||||
|
||||
protected long mega_node_size = 0L;
|
||||
|
||||
protected Comparator nodeComparator = new Comparator() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
@ -29,12 +31,21 @@ public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
||||
}
|
||||
};
|
||||
|
||||
public void setMega_node_size(long mega_node_size) {
|
||||
this.mega_node_size = mega_node_size;
|
||||
}
|
||||
|
||||
public long getMega_node_size() {
|
||||
return mega_node_size;
|
||||
}
|
||||
|
||||
public MegaMutableTreeNode() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MegaMutableTreeNode(Object o) {
|
||||
super(o);
|
||||
this.mega_node_size = (long) ((HashMap<String, Object>) o).get("size");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,7 +55,7 @@ public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
||||
|
||||
HashMap<String, Object> user_object = (HashMap<String, Object>) userObject;
|
||||
|
||||
return user_object.get("name") + ((isLeaf() && user_object.get("size") != null) ? " [" + formatBytes((long) user_object.get("size")) + "]" : "");
|
||||
return user_object.get("name") + " [" + formatBytes(mega_node_size) + "]";
|
||||
|
||||
} else if (userObject instanceof Object) {
|
||||
|
||||
@ -64,7 +75,6 @@ public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
||||
@Override
|
||||
public void insert(MutableTreeNode newChild, int childIndex) {
|
||||
super.insert(newChild, childIndex);
|
||||
Collections.sort(this.children, nodeComparator);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -499,6 +499,24 @@ public class MiscTools {
|
||||
return df.format(bytes_double) + ' ' + units[pow];
|
||||
}
|
||||
|
||||
public static MegaMutableTreeNode calculateTreeFolderSizes(MegaMutableTreeNode node) {
|
||||
|
||||
int n = node.getChildCount();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
if (node.getChildAt(i).isLeaf()) {
|
||||
node.setMega_node_size(node.getMega_node_size() + ((MegaMutableTreeNode) node.getChildAt(i)).getMega_node_size());
|
||||
} else {
|
||||
calculateTreeFolderSizes((MegaMutableTreeNode) node.getChildAt(i));
|
||||
node.setMega_node_size(node.getMega_node_size() + ((MegaMutableTreeNode) node.getChildAt(i)).getMega_node_size());
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
|
||||
}
|
||||
|
||||
public static DefaultMutableTreeNode sortTree(DefaultMutableTreeNode root) {
|
||||
|
||||
Enumeration e = root.depthFirstEnumeration();
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 174 KiB After Width: | Height: | Size: 184 KiB |
Loading…
x
Reference in New Issue
Block a user