mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-04-29 22:24:32 +02:00
7.31
https://github.com/tonikelope/megabasterd/issues/278 -ADVANCED SETTINGS -> DEBUG FILE (default unselected) https://github.com/tonikelope/megabasterd/issues/269 - PROVISION THREAD POOL (MAX 50) - Transfers starts immediately
This commit is contained in:
parent
033fc36d92
commit
bf2a9979cd
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>7.30</version>
|
||||
<version>7.31</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2020 tonikelope
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.tonikelope.megabasterd;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tonikelope
|
||||
*/
|
||||
public class BoundedExecutor {
|
||||
|
||||
private final ExecutorService exec;
|
||||
private final Semaphore semaphore;
|
||||
|
||||
public BoundedExecutor(ExecutorService exec, int bound) {
|
||||
this.exec = exec;
|
||||
this.semaphore = new Semaphore(bound);
|
||||
}
|
||||
|
||||
public void submitTask(final Runnable command)
|
||||
throws InterruptedException {
|
||||
|
||||
semaphore.acquire();
|
||||
try {
|
||||
exec.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
command.run();
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (RejectedExecutionException e) {
|
||||
|
||||
semaphore.release();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "7.30";
|
||||
public static final String VERSION = "7.31";
|
||||
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;
|
||||
@ -101,20 +101,6 @@ public final class MainPanel {
|
||||
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
|
||||
defaults.put("nimbusOrange", defaults.get("nimbusFocus"));
|
||||
|
||||
PrintStream fileOut;
|
||||
|
||||
try {
|
||||
fileOut = new PrintStream(new FileOutputStream(System.getProperty("user.home") + "/.MEGABASTERD_DEBUG.log"));
|
||||
|
||||
System.setOut(fileOut);
|
||||
System.setErr(fileOut);
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
System.out.println(System.getProperty("os.name") + "" + System.getProperty("java.vm.name") + " " + System.getProperty("java.version") + " " + System.getProperty("java.home"));
|
||||
|
||||
_app_image = false;
|
||||
|
||||
if (args.length > 0) {
|
||||
@ -201,7 +187,7 @@ public final class MainPanel {
|
||||
private final UploadManager _upload_manager;
|
||||
private final StreamThrottlerSupervisor _stream_supervisor;
|
||||
private int _max_dl, _max_ul, _default_slots_down, _default_slots_up, _max_dl_speed, _max_up_speed;
|
||||
private boolean _use_slots_down, _limit_download_speed, _limit_upload_speed, _use_mega_account_down, _init_paused;
|
||||
private boolean _use_slots_down, _limit_download_speed, _limit_upload_speed, _use_mega_account_down, _init_paused, _debug_file;
|
||||
private String _mega_account_down;
|
||||
private String _default_download_path;
|
||||
private boolean _use_custom_chunks_dir;
|
||||
@ -266,6 +252,23 @@ public final class MainPanel {
|
||||
|
||||
loadUserSettings();
|
||||
|
||||
if (_debug_file) {
|
||||
|
||||
PrintStream fileOut;
|
||||
|
||||
try {
|
||||
fileOut = new PrintStream(new FileOutputStream(System.getProperty("user.home") + "/.MEGABASTERD_DEBUG.log"));
|
||||
|
||||
System.setOut(fileOut);
|
||||
System.setErr(fileOut);
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(System.getProperty("os.name") + "" + System.getProperty("java.vm.name") + " " + System.getProperty("java.version") + " " + System.getProperty("java.home"));
|
||||
|
||||
UIManager.put("OptionPane.messageFont", GUI_FONT.deriveFont(15f * getZoom_factor()));
|
||||
|
||||
UIManager.put("OptionPane.buttonFont", GUI_FONT.deriveFont(15f * getZoom_factor()));
|
||||
@ -857,6 +860,15 @@ public final class MainPanel {
|
||||
if (_language == null) {
|
||||
_language = DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
String debug_file = selectSettingValue("debug_file");
|
||||
|
||||
if (debug_file != null) {
|
||||
_debug_file = debug_file.equals("yes");
|
||||
} else {
|
||||
_debug_file = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static synchronized void run_external_command() {
|
||||
|
@ -790,41 +790,41 @@ public class MiscTools {
|
||||
data = extensionURL2NormalLink(data);
|
||||
}
|
||||
|
||||
ArrayList<String> links = new ArrayList<>();
|
||||
String url_decoded;
|
||||
try {
|
||||
|
||||
ArrayList<String> links = new ArrayList<>();
|
||||
|
||||
ArrayList<String> base64_chunks = findAllRegex("[A-Za-z0-9+/_-]+=*", URLDecoder.decode(data, "UTF-8"), 0);
|
||||
|
||||
if (!base64_chunks.isEmpty()) {
|
||||
|
||||
for (String chunk : base64_chunks) {
|
||||
|
||||
try {
|
||||
|
||||
String clean_data = MiscTools.newMegaLinks2Legacy(new String(Base64.getDecoder().decode(chunk)));
|
||||
|
||||
String decoded = MiscTools.findFirstRegex("(?:https?|mega)://[^\r\n]+(#[^\r\n!]*?)?![^\r\n!]+![^\\?\r\n]+", clean_data, 0);
|
||||
|
||||
if (decoded != null) {
|
||||
links.add(decoded);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
String clean_data = MiscTools.newMegaLinks2Legacy(URLDecoder.decode(data, "UTF-8"));
|
||||
|
||||
links.addAll(findAllRegex("(?:https?|mega)://[^\r\n]+(#[^\r\n!]*?)?![^\r\n!]+![^\\?\r\n]+", clean_data, 0));
|
||||
|
||||
links.addAll(findAllRegex("mega://e(n|l)c[^\r\n]+", clean_data, 0));
|
||||
|
||||
res = links.stream().map((s) -> s + "\n").reduce(res, String::concat);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
|
||||
url_decoded = URLDecoder.decode(data, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
url_decoded = data;
|
||||
}
|
||||
ArrayList<String> base64_chunks = findAllRegex("[A-Za-z0-9+/_-]+=*", url_decoded, 0);
|
||||
if (!base64_chunks.isEmpty()) {
|
||||
|
||||
for (String chunk : base64_chunks) {
|
||||
|
||||
try {
|
||||
|
||||
String clean_data = MiscTools.newMegaLinks2Legacy(new String(Base64.getDecoder().decode(chunk)));
|
||||
|
||||
String decoded = MiscTools.findFirstRegex("(?:https?|mega)://[^\r\n]+(#[^\r\n!]*?)?![^\r\n!]+![^\\?\r\n]+", clean_data, 0);
|
||||
|
||||
if (decoded != null) {
|
||||
links.add(decoded);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
};
|
||||
}
|
||||
}
|
||||
try {
|
||||
url_decoded = URLDecoder.decode(data, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
url_decoded = data;
|
||||
}
|
||||
String clean_data = MiscTools.newMegaLinks2Legacy(url_decoded);
|
||||
links.addAll(findAllRegex("(?:https?|mega)://[^\r\n]+(#[^\r\n!]*?)?![^\r\n!]+![^\\?\r\n]+", clean_data, 0));
|
||||
links.addAll(findAllRegex("mega://e(n|l)c[^\r\n]+", clean_data, 0));
|
||||
res = links.stream().map((s) -> s + "\n").reduce(res, String::concat);
|
||||
}
|
||||
|
||||
return res.trim();
|
||||
|
@ -48,7 +48,7 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="panel_tabs" pref="474" max="32767" attributes="0"/>
|
||||
<Component id="panel_tabs" pref="805" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
@ -799,7 +799,7 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="mega_accounts_scrollpane" pref="89" max="32767" attributes="0"/>
|
||||
<Component id="mega_accounts_scrollpane" pref="254" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="remove_mega_account_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -808,7 +808,7 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="elc_accounts_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="elc_accounts_scrollpane" pref="89" max="32767" attributes="0"/>
|
||||
<Component id="elc_accounts_scrollpane" pref="255" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="remove_elc_account_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -1047,10 +1047,9 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="run_command_textbox" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jSeparator15" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="jSeparator12" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
|
||||
@ -1083,9 +1082,11 @@
|
||||
<Component id="jButton1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="run_command_textbox" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="proxy_panel" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="debug_file_checkbox" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="start_frozen_checkbox" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="custom_chunks_dir_checkbox" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
@ -1102,6 +1103,7 @@
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jSeparator2" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -1144,6 +1146,10 @@
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jSeparator15" min="-2" pref="8" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="debug_file_checkbox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jSeparator2" min="-2" pref="10" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="run_command_checkbox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="run_command_test_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -1154,7 +1160,7 @@
|
||||
<Component id="proxy_panel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="rec_zoom_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -1565,6 +1571,16 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="run_command_test_buttonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="debug_file_checkbox">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Save debug info to file"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSeparator" name="jSeparator2">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
|
@ -547,6 +547,16 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
|
||||
proxy_pass_textfield.setText(DBTools.selectSettingValue("proxy_pass"));
|
||||
|
||||
boolean debug_file = false;
|
||||
|
||||
String debug_file_val = DBTools.selectSettingValue("debug_file");
|
||||
|
||||
if (debug_file_val != null) {
|
||||
debug_file = (debug_file_val.equals("yes"));
|
||||
}
|
||||
|
||||
debug_file_checkbox.setSelected(debug_file);
|
||||
|
||||
String font = DBTools.selectSettingValue("font");
|
||||
|
||||
this.font_combo.addItem(LabelTranslatorSingleton.getInstance().translate("DEFAULT"));
|
||||
@ -696,6 +706,8 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
run_command_textbox = new javax.swing.JTextField();
|
||||
run_command_textbox.addMouseListener(new ContextMenuMouseListener());
|
||||
run_command_test_button = new javax.swing.JButton();
|
||||
debug_file_checkbox = new javax.swing.JCheckBox();
|
||||
jSeparator2 = new javax.swing.JSeparator();
|
||||
status = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
@ -1251,7 +1263,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(mega_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
|
||||
.addComponent(mega_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(accounts_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(remove_mega_account_button)
|
||||
@ -1259,7 +1271,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(elc_accounts_label)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(elc_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
|
||||
.addComponent(elc_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(accounts_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(remove_elc_account_button)
|
||||
@ -1491,18 +1503,20 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
debug_file_checkbox.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
|
||||
debug_file_checkbox.setText("Save debug info to file");
|
||||
|
||||
javax.swing.GroupLayout advanced_panelLayout = new javax.swing.GroupLayout(advanced_panel);
|
||||
advanced_panel.setLayout(advanced_panelLayout);
|
||||
advanced_panelLayout.setHorizontalGroup(
|
||||
advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, advanced_panelLayout.createSequentialGroup()
|
||||
.addGroup(advanced_panelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(run_command_textbox)
|
||||
.addComponent(jSeparator15)
|
||||
.addComponent(jSeparator12)
|
||||
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jSeparator15, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jSeparator12, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jSeparator1)
|
||||
.addGroup(advanced_panelLayout.createSequentialGroup()
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(advanced_panelLayout.createSequentialGroup()
|
||||
.addComponent(font_label)
|
||||
@ -1524,21 +1538,24 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(export_settings_button))
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addComponent(proxy_panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(start_frozen_checkbox, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(custom_chunks_dir_checkbox, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
|
||||
.addComponent(run_command_textbox, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(proxy_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(advanced_panelLayout.createSequentialGroup()
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(debug_file_checkbox)
|
||||
.addComponent(start_frozen_checkbox)
|
||||
.addComponent(custom_chunks_dir_checkbox)
|
||||
.addGroup(advanced_panelLayout.createSequentialGroup()
|
||||
.addComponent(custom_chunks_dir_button)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(custom_chunks_dir_current_label))
|
||||
.addComponent(rec_zoom_label, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
|
||||
.addComponent(rec_zoom_label)
|
||||
.addGroup(advanced_panelLayout.createSequentialGroup()
|
||||
.addComponent(run_command_checkbox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(run_command_test_button)))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addComponent(jSeparator2))
|
||||
.addContainerGap())
|
||||
);
|
||||
advanced_panelLayout.setVerticalGroup(
|
||||
@ -1574,6 +1591,10 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jSeparator15, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(debug_file_checkbox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(run_command_checkbox)
|
||||
.addComponent(run_command_test_button))
|
||||
@ -1583,7 +1604,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
.addComponent(proxy_panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(rec_zoom_label)
|
||||
.addContainerGap())
|
||||
.addGap(34, 34, 34))
|
||||
);
|
||||
|
||||
advanced_scrollpane.setViewportView(advanced_panel);
|
||||
@ -1613,7 +1634,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(panel_tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
|
||||
.addComponent(panel_tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 805, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
@ -1664,6 +1685,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
settings.put("smart_proxy", smart_proxy_checkbox.isSelected() ? "yes" : "no");
|
||||
settings.put("start_frozen", start_frozen_checkbox.isSelected() ? "yes" : "no");
|
||||
settings.put("use_custom_chunks_dir", custom_chunks_dir_checkbox.isSelected() ? "yes" : "no");
|
||||
settings.put("debug_file", debug_file_checkbox.isSelected() ? "yes" : "no");
|
||||
settings.put("custom_chunks_dir", _custom_chunks_dir);
|
||||
settings.put("custom_proxy_list", custom_proxy_textarea.getText());
|
||||
settings.put("run_command", run_command_checkbox.isSelected() ? "yes" : "no");
|
||||
@ -1705,7 +1727,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
|
||||
if (old_zoom == null) {
|
||||
|
||||
old_zoom = "100";
|
||||
old_zoom = String.valueOf(Math.round(100 * MainPanel.ZOOM_FACTOR));
|
||||
}
|
||||
|
||||
String zoom = String.valueOf(zoom_spinner.getValue());
|
||||
@ -1765,7 +1787,9 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
|
||||
insertSettingsValues(settings);
|
||||
|
||||
if (!font.equals(old_font) || !language.equals(old_language) || !zoom.equals(old_zoom)
|
||||
if (!font.equals(old_font)
|
||||
|| !language.equals(old_language)
|
||||
|| !zoom.equals(old_zoom)
|
||||
|| use_proxy != old_use_proxy
|
||||
|| !proxy_host.equals(old_proxy_host)
|
||||
|| !proxy_port.equals(old_proxy_port)
|
||||
@ -2857,6 +2881,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JLabel custom_chunks_dir_current_label;
|
||||
private javax.swing.JLabel custom_proxy_list_label;
|
||||
private javax.swing.JTextArea custom_proxy_textarea;
|
||||
private javax.swing.JCheckBox debug_file_checkbox;
|
||||
private javax.swing.JLabel default_dir_label;
|
||||
private javax.swing.JLabel default_slots_down_label;
|
||||
private javax.swing.JSpinner default_slots_down_spinner;
|
||||
@ -2884,6 +2909,7 @@ public class SettingsDialog extends javax.swing.JDialog {
|
||||
private javax.swing.JSeparator jSeparator11;
|
||||
private javax.swing.JSeparator jSeparator12;
|
||||
private javax.swing.JSeparator jSeparator15;
|
||||
private javax.swing.JSeparator jSeparator2;
|
||||
private javax.swing.JSeparator jSeparator3;
|
||||
private javax.swing.JSeparator jSeparator4;
|
||||
private javax.swing.JSeparator jSeparator5;
|
||||
|
@ -6,6 +6,8 @@ import java.awt.TrayIcon;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import static java.util.logging.Level.SEVERE;
|
||||
import java.util.logging.Logger;
|
||||
@ -18,6 +20,7 @@ import javax.swing.JPanel;
|
||||
abstract public class TransferenceManager implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
public static final int MAX_WAIT_QUEUE = 1000;
|
||||
public static final int MAX_PROVISION_WORKERS = 50;
|
||||
private static final Logger LOG = Logger.getLogger(TransferenceManager.class.getName());
|
||||
|
||||
private final ConcurrentLinkedQueue<Object> _transference_preprocess_global_queue;
|
||||
@ -734,13 +737,30 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
||||
THREAD_POOL.execute(() -> {
|
||||
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(MAX_PROVISION_WORKERS);
|
||||
|
||||
BoundedExecutor bounded_executor = new BoundedExecutor(executor, MAX_PROVISION_WORKERS);
|
||||
|
||||
while (!getTransference_provision_queue().isEmpty() || isPreprocessing_transferences()) {
|
||||
Transference transference = getTransference_provision_queue().poll();
|
||||
|
||||
if (transference != null) {
|
||||
|
||||
provision(transference);
|
||||
boolean error;
|
||||
|
||||
do {
|
||||
error = false;
|
||||
|
||||
try {
|
||||
bounded_executor.submitTask(() -> {
|
||||
provision(transference);
|
||||
});
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(TransferenceManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
error = true;
|
||||
MiscTools.pausar(1000);
|
||||
}
|
||||
} while (error);
|
||||
}
|
||||
|
||||
if (isPreprocessing_transferences()) {
|
||||
@ -755,6 +775,12 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
||||
}
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
|
||||
while (!executor.isTerminated()) {
|
||||
MiscTools.pausar(1000);
|
||||
}
|
||||
|
||||
synchronized (_transference_queue_sort_lock) {
|
||||
|
||||
if (getSort_wait_start_queue()) {
|
||||
@ -803,7 +829,7 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
||||
|
||||
}
|
||||
|
||||
if (!_frozen && !_main_panel.isExit() && !_paused_all && !isRemoving_transferences() && !isStarting_transferences() && !getTransference_waitstart_queue().isEmpty() && getTransference_running_list().size() < _max_running_trans) {
|
||||
if (!_frozen && !_main_panel.isExit() && !_paused_all && !isRemoving_transferences() && !isStarting_transferences() && (!getTransference_waitstart_queue().isEmpty() || !getTransference_waitstart_aux_queue().isEmpty()) && getTransference_running_list().size() < _max_running_trans) {
|
||||
|
||||
setStarting_transferences(true);
|
||||
|
||||
@ -811,20 +837,25 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
||||
|
||||
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
|
||||
|
||||
while (!_frozen && !_main_panel.isExit() && !_paused_all && !getTransference_waitstart_queue().isEmpty() && getTransference_running_list().size() < _max_running_trans) {
|
||||
while (!_frozen && !_main_panel.isExit() && !_paused_all && (!getTransference_waitstart_queue().isEmpty() || !getTransference_waitstart_aux_queue().isEmpty()) && getTransference_running_list().size() < _max_running_trans) {
|
||||
|
||||
Transference transference = getTransference_waitstart_queue().peek();
|
||||
synchronized (_transference_queue_sort_lock) {
|
||||
Transference transference = getTransference_waitstart_queue().peek();
|
||||
|
||||
if (transference != null && !transference.isFrozen()) {
|
||||
if (transference == null) {
|
||||
transference = getTransference_waitstart_aux_queue().peek();
|
||||
}
|
||||
|
||||
getTransference_waitstart_queue().poll();
|
||||
if (transference != null && !transference.isFrozen()) {
|
||||
|
||||
start(transference);
|
||||
getTransference_waitstart_queue().remove(transference);
|
||||
getTransference_waitstart_aux_queue().remove(transference);
|
||||
|
||||
} else {
|
||||
|
||||
_frozen = true;
|
||||
start(transference);
|
||||
|
||||
} else {
|
||||
_frozen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 242 KiB After Width: | Height: | Size: 173 KiB |
Loading…
x
Reference in New Issue
Block a user