mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
Images download: decrease default images threads to 3 instead 10 (scryfall IP ban workaround for massive download)
This commit is contained in:
parent
3bf0f80033
commit
401d468494
2 changed files with 8 additions and 8 deletions
|
@ -79,6 +79,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault";
|
||||
public static final String KEY_CARD_IMAGES_PATH = "cardImagesPath";
|
||||
public static final String KEY_CARD_IMAGES_THREADS = "cardImagesThreads";
|
||||
public static final String KEY_CARD_IMAGES_THREADS_DEFAULT = "3";
|
||||
public static final String KEY_CARD_IMAGES_SAVE_TO_ZIP = "cardImagesSaveToZip";
|
||||
public static final String KEY_CARD_IMAGES_PREF_LANGUAGE = "cardImagesPreferedImageLaguage";
|
||||
|
||||
|
@ -3465,7 +3466,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
updateCache(KEY_CARD_IMAGES_PATH, path);
|
||||
}
|
||||
load(prefs, dialog.cbSaveToZipFiles, KEY_CARD_IMAGES_SAVE_TO_ZIP, "true");
|
||||
dialog.cbNumberOfDownloadThreads.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_IMAGES_THREADS, "10"));
|
||||
dialog.cbNumberOfDownloadThreads.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_IMAGES_THREADS, KEY_CARD_IMAGES_THREADS_DEFAULT));
|
||||
dialog.cbPreferedImageLanguage.setSelectedItem(MageFrame.getPreferences().get(KEY_CARD_IMAGES_PREF_LANGUAGE, CardLanguage.ENGLISH.getCode()));
|
||||
|
||||
// rendering settings
|
||||
|
@ -3762,10 +3763,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
if (CACHE.containsKey(key)) {
|
||||
return CACHE.get(key);
|
||||
} else {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
String value = prefs.get(key, def);
|
||||
String value = MageFrame.getPreferences().get(key, def);
|
||||
if (value == null) {
|
||||
return null;
|
||||
return def;
|
||||
}
|
||||
CACHE.put(key, value);
|
||||
return value;
|
||||
|
|
|
@ -51,18 +51,18 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
|
||||
private static final int MAX_ERRORS_COUNT_BEFORE_CANCEL = 50;
|
||||
|
||||
private DownloadImagesDialog uiDialog;
|
||||
private final DownloadImagesDialog uiDialog;
|
||||
private boolean needCancel;
|
||||
private int errorCount;
|
||||
private int cardIndex;
|
||||
|
||||
private List<CardInfo> cardsAll;
|
||||
private List<CardDownloadData> cardsMissing;
|
||||
private List<CardDownloadData> cardsDownloadQueue;
|
||||
private final List<CardDownloadData> cardsDownloadQueue;
|
||||
private int missingCardsCount = 0;
|
||||
private int missingTokensCount = 0;
|
||||
|
||||
private List<String> selectedSets = new ArrayList<>();
|
||||
private final List<String> selectedSets = new ArrayList<>();
|
||||
private static CardImageSource selectedSource;
|
||||
|
||||
private final Object sync = new Object();
|
||||
|
@ -617,7 +617,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
uiDialog.getProgressBar().setString("Preparing download list...");
|
||||
if (selectedSource.prepareDownloadList(this, cardsDownloadQueue)) {
|
||||
update(0, cardsDownloadQueue.size());
|
||||
int numberOfThreads = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_THREADS, "10"));
|
||||
int numberOfThreads = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_THREADS, PreferencesDialog.KEY_CARD_IMAGES_THREADS_DEFAULT));
|
||||
ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
|
||||
for (int i = 0; i < cardsDownloadQueue.size() && !this.isNeedCancel(); i++) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue