import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Story;
-import be.nikiroo.fanfix.output.BasicOutput.OutputType;
import be.nikiroo.utils.Progress;
import be.nikiroo.utils.Version;
import be.nikiroo.utils.serial.ConnectActionClient;
this.baseDir = Instance.getRemoteDir(host);
this.baseDir.mkdirs();
- this.lib = new LocalLibrary(baseDir, OutputType.INFO_TEXT,
- OutputType.CBZ);
+ this.lib = new LocalLibrary(baseDir);
}
@Override
metas = new ArrayList<MetaData>();
try {
- new ConnectActionClient(host, port, true, null) {
+ new ConnectActionClient(host, port, true) {
@Override
public void action(Version serverVersion) throws Exception {
try {
} catch (IOException e) {
Instance.syserr(e);
}
+
+ List<String> test = new ArrayList<String>();
+ for (MetaData meta : metas) {
+ if (test.contains(meta.getLuid())) {
+ throw new RuntimeException("wwops");
+ }
+ test.add(meta.getLuid());
+ }
}
return metas;
if (file == null) {
final File[] tmp = new File[1];
try {
- new ConnectActionClient(host, port, true, null) {
+ new ConnectActionClient(host, port, true) {
@Override
public void action(Version serverVersion) throws Exception {
try {
}
@Override
- public BufferedImage getCover(String luid) {
- // Retrieve it from the network if needed:
- if (lib.getInfo(luid) == null) {
- getFile(luid);
+ public BufferedImage getCover(final String luid) {
+ // Retrieve it from the cache if possible:
+ if (lib.getInfo(luid) != null) {
+ return lib.getCover(luid);
+ }
+
+ final BufferedImage[] result = new BufferedImage[1];
+ try {
+ new ConnectActionClient(host, port, true) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ try {
+ Object rep = send("GET_COVER " + luid);
+ result[0] = (BufferedImage) rep;
+ } catch (Exception e) {
+ Instance.syserr(e);
+ }
+ }
+ }.connect();
+ } catch (IOException e) {
+ Instance.syserr(e);
}
- return lib.getCover(luid);
+ return result[0];
}
@Override
protected Story doSave(Story story, Progress pg) throws IOException {
throw new java.lang.InternalError("Should not have been called");
}
+
+ /**
+ * Return the backing local library.
+ *
+ * @return the library
+ */
+ LocalLibrary getLocalLibrary() {
+ return lib;
+ }
}