mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Added code to check for folder existence and create if necessary.
Added a 2.5 second pause to the download loop to alleviate the server a bit.
This commit is contained in:
@@ -219,6 +219,14 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
|
|
||||||
File f = new File(base, cName);
|
File f = new File(base, cName);
|
||||||
|
|
||||||
|
//test for folder existence
|
||||||
|
File test = new File(base, cards[card].folder);
|
||||||
|
if (!test.exists()) {
|
||||||
|
// create folder
|
||||||
|
if (!test.mkdir())
|
||||||
|
System.out.println("Can't create folder" + cards[card].folder);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
in = new BufferedInputStream(new URL(url).openConnection(p).getInputStream());
|
in = new BufferedInputStream(new URL(url).openConnection(p).getInputStream());
|
||||||
out = new BufferedOutputStream(new FileOutputStream(f));
|
out = new BufferedOutputStream(new FileOutputStream(f));
|
||||||
@@ -249,11 +257,21 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(FileNotFoundException fnfe) {
|
catch(FileNotFoundException fnfe) {
|
||||||
System.out.println("Error - the LQ picture for "+cards[card].name+" could not be found on the server.");
|
System.out.println("Error - the LQ picture for " + cards[card].name + " could not be found on the server. [" + cards[card].url + "] - " + fnfe.getMessage());
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception ex) {
|
||||||
Log.error("LQ Pictures", "Error downloading pictures", ex);
|
Log.error("LQ Pictures", "Error downloading pictures", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pause
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(2442);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
Log.error("LQ Set Pictures", "Sleep Error", e);
|
||||||
|
}
|
||||||
}//for
|
}//for
|
||||||
}
|
}
|
||||||
close.setText(ForgeProps.getLocalized(BUTTONS.CLOSE));
|
close.setText(ForgeProps.getLocalized(BUTTONS.CLOSE));
|
||||||
@@ -315,7 +333,7 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
if (imgFN.equals("none") || (!imgFN.contains(SC3) && !imgFN.contains(SC2)))
|
if (imgFN.equals("none") || (!imgFN.contains(SC3) && !imgFN.contains(SC2)))
|
||||||
{
|
{
|
||||||
String fn = GuiDisplayUtil.cleanStringMWS(c.getName()) + n + ".full.jpg";
|
String fn = GuiDisplayUtil.cleanStringMWS(c.getName()) + n + ".full.jpg";
|
||||||
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true)));
|
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,7 +345,7 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
if (imgFN.equals("none") || (!imgFN.contains(SC3) && !imgFN.contains(SC2)))
|
if (imgFN.equals("none") || (!imgFN.contains(SC3) && !imgFN.contains(SC2)))
|
||||||
{
|
{
|
||||||
String fn = GuiDisplayUtil.cleanStringMWS(c.getName()) + ".full.jpg";
|
String fn = GuiDisplayUtil.cleanStringMWS(c.getName()) + ".full.jpg";
|
||||||
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true)));
|
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +387,7 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
line = in.readLine();
|
line = in.readLine();
|
||||||
while(line != null && (!line.equals(""))) {
|
while(line != null && (!line.equals(""))) {
|
||||||
tok = new StringTokenizer(line);
|
tok = new StringTokenizer(line);
|
||||||
list.add(new mCard(tok.nextToken(), tok.nextToken()));
|
list.add(new mCard(tok.nextToken(), tok.nextToken(), ""));
|
||||||
|
|
||||||
line = in.readLine();
|
line = in.readLine();
|
||||||
}
|
}
|
||||||
@@ -403,10 +421,12 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
private static class mCard {
|
private static class mCard {
|
||||||
final public String name;
|
final public String name;
|
||||||
final public String url;
|
final public String url;
|
||||||
|
final public String folder;
|
||||||
|
|
||||||
mCard(String cardName, String cardURL) {
|
mCard(String cardName, String cardURL, String cardFolder) {
|
||||||
name = cardName;
|
name = cardName;
|
||||||
url = cardURL;
|
url = cardURL;
|
||||||
|
folder = cardFolder;
|
||||||
}
|
}
|
||||||
}//mCard
|
}//mCard
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user