mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-03 08:04:27 +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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.tonikelope</groupId>
|
<groupId>com.tonikelope</groupId>
|
||||||
<artifactId>MegaBasterd</artifactId>
|
<artifactId>MegaBasterd</artifactId>
|
||||||
<version>7.51</version>
|
<version>7.52</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -15,13 +15,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.9.6</version>
|
<version>2.12.6</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.9.9</version>
|
<version>2.12.6</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -24,11 +24,12 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="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"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
<Component id="link_detected_label" max="32767" attributes="0"/>
|
<Component id="node_bar" max="32767" attributes="0"/>
|
||||||
<Component id="file_tree_scrollpane" 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="total_space_label" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="warning_label" alignment="0" max="32767" attributes="0"/>
|
<Component id="warning_label" alignment="0" max="32767" attributes="0"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
@ -52,25 +53,24 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="1" attributes="0">
|
<Component id="link_detected_label" min="-2" max="-2" attributes="0"/>
|
||||||
<Group type="102" attributes="0">
|
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Component id="folder_link_label" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="skip_rest_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="restore_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="skip_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
</Group>
|
||||||
<Component id="dance_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
<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>
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" alignment="1" 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"/>
|
|
||||||
<Component id="total_space_label" min="-2" max="-2" attributes="0"/>
|
<Component id="total_space_label" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="warning_label" min="-2" 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"/>
|
<Property name="enabled" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JProgressBar" name="node_bar">
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -72,6 +72,8 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
translateLabels(this);
|
translateLabels(this);
|
||||||
|
|
||||||
|
node_bar.setIndeterminate(true);
|
||||||
|
|
||||||
folder_link_label.setText(link);
|
folder_link_label.setText(link);
|
||||||
|
|
||||||
restore_button.setVisible(false);
|
restore_button.setVisible(false);
|
||||||
@ -133,6 +135,7 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
skip_rest_button = new javax.swing.JButton();
|
skip_rest_button = new javax.swing.JButton();
|
||||||
restore_button = new javax.swing.JButton();
|
restore_button = new javax.swing.JButton();
|
||||||
total_space_label = new javax.swing.JLabel();
|
total_space_label = new javax.swing.JLabel();
|
||||||
|
node_bar = new javax.swing.JProgressBar();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
setTitle("FolderLink");
|
setTitle("FolderLink");
|
||||||
@ -211,20 +214,21 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(link_detected_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(node_bar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(file_tree_scrollpane)
|
.addComponent(link_detected_label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(total_space_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(warning_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(total_space_label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.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)
|
.addComponent(skip_rest_button)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
.addComponent(skip_button)
|
.addComponent(skip_button)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(dance_button))
|
.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)
|
.addComponent(folder_link_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(restore_button)))
|
.addComponent(restore_button)))
|
||||||
@ -234,22 +238,22 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
.addComponent(link_detected_label)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGap(8, 8, 8)
|
||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addComponent(folder_link_label)
|
||||||
.addComponent(skip_rest_button)
|
.addComponent(restore_button))
|
||||||
.addComponent(skip_button)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(dance_button)))
|
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(link_detected_label)
|
.addComponent(node_bar, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(8, 8, 8)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(folder_link_label)
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(restore_button))
|
.addComponent(skip_rest_button)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addComponent(skip_button)
|
||||||
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
|
.addComponent(dance_button))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addComponent(total_space_label)
|
.addComponent(total_space_label)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(warning_label)
|
.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
|
private void skip_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_buttonActionPerformed
|
||||||
|
|
||||||
if (deleteSelectedTreeItems(file_tree)) {
|
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
|
private void skip_rest_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_rest_buttonActionPerformed
|
||||||
|
|
||||||
if (deleteAllExceptSelectedTreeItems(file_tree)) {
|
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_rest_button.setEnabled(root_childs);
|
||||||
|
});
|
||||||
skip_button.setEnabled(root_childs);
|
});
|
||||||
|
|
||||||
skip_rest_button.setEnabled(root_childs);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_skip_rest_buttonActionPerformed
|
}//GEN-LAST:event_skip_rest_buttonActionPerformed
|
||||||
@ -316,6 +331,10 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
dance_button.setEnabled(false);
|
dance_button.setEnabled(false);
|
||||||
|
|
||||||
|
node_bar.setVisible(true);
|
||||||
|
|
||||||
|
node_bar.setIndeterminate(true);
|
||||||
|
|
||||||
THREAD_POOL.execute(() -> {
|
THREAD_POOL.execute(() -> {
|
||||||
_loadMegaDirTree();
|
_loadMegaDirTree();
|
||||||
_genDownloadLiks();
|
_genDownloadLiks();
|
||||||
@ -348,12 +367,30 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
String folder_key = findFirstRegex("#F![^!]+!(.+)", _link, 1);
|
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;
|
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()) {
|
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;
|
HashMap<String, Object> current_hashmap_node = (HashMap<String, Object>) o;
|
||||||
|
|
||||||
MegaMutableTreeNode current_node;
|
MegaMutableTreeNode current_node;
|
||||||
@ -406,6 +443,15 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
} while (current_node != root);
|
} while (current_node != root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MiscTools.GUIRun(() -> {
|
||||||
|
|
||||||
|
node_bar.setIndeterminate(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
MiscTools.sortTree(root);
|
||||||
|
|
||||||
|
MiscTools.calculateTreeFolderSizes(root);
|
||||||
|
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
LOG.log(SEVERE, null, "MEGA FOLDER ERROR (EMPTY?)");
|
LOG.log(SEVERE, null, "MEGA FOLDER ERROR (EMPTY?)");
|
||||||
|
|
||||||
@ -417,7 +463,10 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
final MegaMutableTreeNode roott = root;
|
final MegaMutableTreeNode roott = root;
|
||||||
|
|
||||||
MiscTools.GUIRun(() -> {
|
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);
|
ftree.setRootVisible(roott != null ? roott.getChildCount() > 0 : false);
|
||||||
|
|
||||||
@ -447,74 +496,77 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void _genDownloadLiks() {
|
private void _genDownloadLiks() {
|
||||||
|
|
||||||
MiscTools.GUIRunAndWait(() -> {
|
MiscTools.GUIRun(() -> {
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
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 += 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 = 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) + "]");
|
total_space_label.setText("[" + formatBytes(_total_space) + "]");
|
||||||
|
|
||||||
@ -523,6 +575,8 @@ public class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
c.setEnabled(root.getChildCount() > 0);
|
c.setEnabled(root.getChildCount() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node_bar.setVisible(false);
|
||||||
|
|
||||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
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.JScrollPane file_tree_scrollpane;
|
||||||
private javax.swing.JLabel folder_link_label;
|
private javax.swing.JLabel folder_link_label;
|
||||||
private javax.swing.JLabel link_detected_label;
|
private javax.swing.JLabel link_detected_label;
|
||||||
|
private javax.swing.JProgressBar node_bar;
|
||||||
private javax.swing.JButton restore_button;
|
private javax.swing.JButton restore_button;
|
||||||
private javax.swing.JButton skip_button;
|
private javax.swing.JButton skip_button;
|
||||||
private javax.swing.JButton skip_rest_button;
|
private javax.swing.JButton skip_rest_button;
|
||||||
|
@ -58,7 +58,7 @@ import javax.swing.UIManager;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
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 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;
|
||||||
|
@ -25,6 +25,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -932,7 +933,7 @@ public class MegaAPI implements Serializable {
|
|||||||
return ch;
|
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;
|
HashMap<String, Object> folder_nodes = null;
|
||||||
|
|
||||||
@ -950,8 +951,27 @@ public class MegaAPI implements Serializable {
|
|||||||
|
|
||||||
folder_nodes = new HashMap<>();
|
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")) {
|
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;
|
HashMap<String, Object> node = (HashMap<String, Object>) o;
|
||||||
|
|
||||||
String[] node_k = ((String) node.get("k")).split(":");
|
String[] node_k = ((String) node.get("k")).split(":");
|
||||||
@ -984,6 +1004,8 @@ public class MegaAPI implements Serializable {
|
|||||||
long size = (Long) node.get("s");
|
long size = (Long) node.get("s");
|
||||||
the_node.put("size", size);
|
the_node.put("size", size);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
the_node.put("size", 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
the_node.put("name", at.get("n"));
|
the_node.put("name", at.get("n"));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.tonikelope.megabasterd;
|
package com.tonikelope.megabasterd;
|
||||||
|
|
||||||
import static com.tonikelope.megabasterd.MiscTools.*;
|
import static com.tonikelope.megabasterd.MiscTools.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -15,6 +14,9 @@ import javax.swing.tree.MutableTreeNode;
|
|||||||
public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(MegaMutableTreeNode.class.getName());
|
private static final Logger LOG = Logger.getLogger(MegaMutableTreeNode.class.getName());
|
||||||
|
|
||||||
|
protected long mega_node_size = 0L;
|
||||||
|
|
||||||
protected Comparator nodeComparator = new Comparator() {
|
protected Comparator nodeComparator = new Comparator() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Object o1, Object o2) {
|
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() {
|
public MegaMutableTreeNode() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MegaMutableTreeNode(Object o) {
|
public MegaMutableTreeNode(Object o) {
|
||||||
super(o);
|
super(o);
|
||||||
|
this.mega_node_size = (long) ((HashMap<String, Object>) o).get("size");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +55,7 @@ public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
|||||||
|
|
||||||
HashMap<String, Object> user_object = (HashMap<String, Object>) userObject;
|
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) {
|
} else if (userObject instanceof Object) {
|
||||||
|
|
||||||
@ -64,7 +75,6 @@ public class MegaMutableTreeNode extends DefaultMutableTreeNode {
|
|||||||
@Override
|
@Override
|
||||||
public void insert(MutableTreeNode newChild, int childIndex) {
|
public void insert(MutableTreeNode newChild, int childIndex) {
|
||||||
super.insert(newChild, childIndex);
|
super.insert(newChild, childIndex);
|
||||||
Collections.sort(this.children, nodeComparator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -499,6 +499,24 @@ public class MiscTools {
|
|||||||
return df.format(bytes_double) + ' ' + units[pow];
|
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) {
|
public static DefaultMutableTreeNode sortTree(DefaultMutableTreeNode root) {
|
||||||
|
|
||||||
Enumeration e = root.depthFirstEnumeration();
|
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