X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibrary.java;h=326a488b1766a8fc9ddf5052dae8c8fdb32b11cc;hp=10cc44de423db239067e7318a667d7dd1e2df468;hb=e272f05fd49f01e9fb6bd71c7b74a32839bbcc38;hpb=1b9a09a2d3ddd4558c9f440392e50504421ddb2e diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 10cc44d..326a488 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -233,8 +233,7 @@ public class RemoteLibrary extends BasicLibrary { }.connect(); // because the meta changed: - clearCache(); - refresh(pgRefresh); + invalidateInfo(luidSaved[0]); MetaData meta = getInfo(luidSaved[0]); meta.setCover(story.getMeta().getCover()); @@ -357,8 +356,6 @@ public class RemoteLibrary extends BasicLibrary { rep = send(null); } - - getInfo(luid).setSource(newSource); } @Override @@ -398,8 +395,57 @@ public class RemoteLibrary extends BasicLibrary { } } + @Override + public synchronized MetaData getInfo(String luid) { + List metas = getMetasList(luid, null); + if (!metas.isEmpty()) { + return metas.get(0); + } + + return null; + } + @Override protected List getMetas(Progress pg) { + return getMetasList("*", pg); + } + + @Override + protected void invalidateInfo(String luid) { + } + + // The following methods are only used by Save and Delete in BasicLibrary: + + @Override + protected int getNextId() { + throw new java.lang.InternalError("Should not have been called"); + } + + @Override + protected void doDelete(String luid) throws IOException { + throw new java.lang.InternalError("Should not have been called"); + } + + @Override + protected Story doSave(Story story, Progress pg) throws IOException { + throw new java.lang.InternalError("Should not have been called"); + } + + // + + /** + * Return the meta of the given story or a list of all known metas if the + * luid is "*". + * + * @param luid + * the luid of the story or * + * @param pg + * the optional progress + * + * + * @return the metas + */ + private List getMetasList(final String luid, Progress pg) { final Progress pgF = pg; final List metas = new ArrayList(); @@ -412,7 +458,7 @@ public class RemoteLibrary extends BasicLibrary { pg = new Progress(); } - Object rep = send(new Object[] { md5, "GET_METADATA", "*" }); + Object rep = send(new Object[] { md5, "GET_METADATA", luid }); while (true) { if (!RemoteLibraryServer.updateProgress(pg, rep)) { @@ -422,8 +468,12 @@ public class RemoteLibrary extends BasicLibrary { rep = send(null); } - for (MetaData meta : (MetaData[]) rep) { - metas.add(meta); + if (rep instanceof MetaData[]) { + for (MetaData meta : (MetaData[]) rep) { + metas.add(meta); + } + } else if (rep != null) { + metas.add((MetaData) rep); } } @@ -438,25 +488,4 @@ public class RemoteLibrary extends BasicLibrary { return metas; } - - @Override - protected void clearCache() { - } - - // The following methods are only used by Save and Delete in BasicLibrary: - - @Override - protected int getNextId() { - throw new java.lang.InternalError("Should not have been called"); - } - - @Override - protected void doDelete(String luid) throws IOException { - throw new java.lang.InternalError("Should not have been called"); - } - - @Override - protected Story doSave(Story story, Progress pg) throws IOException { - throw new java.lang.InternalError("Should not have been called"); - } }