download: reworked scryfall images support:

- download: fixed unmount zip errors on cancel download in some use cases (closes #12536);
- download: significant download speed improvements (now it depends on user's network speed, not api limitations);
- download: added additional error dialogs on bad use cases;
- scryfall: added cards and bulk data api support;
- scryfall: added bulk data download (updates once per week, contains all scryfall cards and store in images\downloading folder, 2 GB size);
- scryfall: added optimized images download without api usage (use direct images links from bulk data, closes #11576);
- scryfall: improved image source searching for some use cases (miss or wrong images problems, closes #12511);
- scryfall: tokens don't use bulk data;
- scryfall: 75k small images downloads 40 minutes and takes 1 GB and 2100 api calls (most of it from tokens);
- scryfall: how-to disable bulk data, e.g. for api testing: -Dxmage.scryfallEnableBulkData=false
This commit is contained in:
Oleg Agafonov 2024-08-03 19:41:14 +04:00
parent 46f7304692
commit 0a55e37c8c
19 changed files with 884 additions and 216 deletions

View file

@ -1,25 +1,23 @@
package mage.server.game;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
import mage.game.Game;
import mage.game.GameState;
import mage.game.GameStates;
import mage.server.Main;
import mage.util.CopierObjectInputStream;
import mage.utils.StreamUtils;
import org.apache.log4j.Logger;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
/**
* Replay system, outdated and not used. TODO: delete
*
* @author BetaSteward_at_googlemail.com
*/
@ -59,33 +57,19 @@ public class GameReplay {
}
private Game loadGame(UUID gameId) {
InputStream file = null;
InputStream buffer = null;
InputStream gzip = null;
ObjectInput input = null;
try{
file = new FileInputStream("saved/" + gameId.toString() + ".game");
buffer = new BufferedInputStream(file);
gzip = new GZIPInputStream(buffer);
input = new CopierObjectInputStream(Main.classLoader, gzip);
try (InputStream file = Files.newInputStream(Paths.get("saved/" + gameId.toString() + ".game"));
InputStream buffer = new BufferedInputStream(file);
InputStream gzip = new GZIPInputStream(buffer);
ObjectInput input = new CopierObjectInputStream(Main.classLoader, gzip)) {
Game loadGame = (Game) input.readObject();
GameStates states = (GameStates) input.readObject();
loadGame.loadGameStates(states);
return loadGame;
}
catch(ClassNotFoundException ex) {
logger.fatal("Cannot load game. Class not found.", ex);
}
catch(IOException ex) {
logger.fatal("Cannot load game:" + gameId, ex);
} finally {
StreamUtils.closeQuietly(file);
StreamUtils.closeQuietly(buffer);
StreamUtils.closeQuietly(input);
StreamUtils.closeQuietly(gzip);
} catch (ClassNotFoundException e) {
logger.fatal("Cannot load game. Class not found.", e);
} catch (IOException e) {
logger.fatal("Cannot load game:" + gameId, e);
}
return null;
}
}