git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge commit '929409950e82914aa3cee323cfa7c5007585d2ea'
[nikiroo-utils.git]
/
src
/
be
/
nikiroo
/
fanfix
/
library
/
CacheLibrary.java
diff --git
a/src/be/nikiroo/fanfix/library/CacheLibrary.java
b/src/be/nikiroo/fanfix/library/CacheLibrary.java
index 8f6e9c29a24bfd128c64e5fe69e90c98a53ac4e3..e8743b63cd9d18ca0ef0ba3316aa204433b4bf34 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/CacheLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/CacheLibrary.java
@@
-52,7
+52,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- protected List<MetaData> getMetas(Progress pg) {
+ protected List<MetaData> getMetas(Progress pg)
throws IOException
{
if (pg == null) {
pg = new Progress();
}
if (pg == null) {
pg = new Progress();
}
@@
-66,7
+66,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public synchronized MetaData getInfo(String luid) {
+ public synchronized MetaData getInfo(String luid)
throws IOException
{
MetaData info = cacheLib.getInfo(luid);
if (info == null) {
info = lib.getInfo(luid);
MetaData info = cacheLib.getInfo(luid);
if (info == null) {
info = lib.getInfo(luid);
@@
-76,7
+76,8
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public synchronized Story getStory(String luid, MetaData meta, Progress pg) {
+ public synchronized Story getStory(String luid, MetaData meta, Progress pg)
+ throws IOException {
if (pg == null) {
pg = new Progress();
}
if (pg == null) {
pg = new Progress();
}
@@
-109,7
+110,8
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public synchronized File getFile(final String luid, Progress pg) {
+ public synchronized File getFile(final String luid, Progress pg)
+ throws IOException {
if (pg == null) {
pg = new Progress();
}
if (pg == null) {
pg = new Progress();
}
@@
-134,7
+136,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public Image getCover(final String luid) {
+ public Image getCover(final String luid)
throws IOException
{
if (isCached(luid)) {
return cacheLib.getCover(luid);
}
if (isCached(luid)) {
return cacheLib.getCover(luid);
}
@@
-144,7
+146,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public Image getSourceCover(String source) {
+ public Image getSourceCover(String source)
throws IOException
{
Image custom = getCustomSourceCover(source);
if (custom != null) {
return custom;
Image custom = getCustomSourceCover(source);
if (custom != null) {
return custom;
@@
-159,7
+161,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public Image getAuthorCover(String author) {
+ public Image getAuthorCover(String author)
throws IOException
{
Image custom = getCustomAuthorCover(author);
if (custom != null) {
return custom;
Image custom = getCustomAuthorCover(author);
if (custom != null) {
return custom;
@@
-174,7
+176,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public Image getCustomSourceCover(String source) {
+ public Image getCustomSourceCover(String source)
throws IOException
{
Image custom = cacheLib.getCustomSourceCover(source);
if (custom == null) {
custom = lib.getCustomSourceCover(source);
Image custom = cacheLib.getCustomSourceCover(source);
if (custom == null) {
custom = lib.getCustomSourceCover(source);
@@
-187,7
+189,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public Image getCustomAuthorCover(String author) {
+ public Image getCustomAuthorCover(String author)
throws IOException
{
Image custom = cacheLib.getCustomAuthorCover(author);
if (custom == null) {
custom = lib.getCustomAuthorCover(author);
Image custom = cacheLib.getCustomAuthorCover(author);
if (custom == null) {
custom = lib.getCustomAuthorCover(author);
@@
-200,25
+202,31
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public void setSourceCover(String source, String luid) {
+ public void setSourceCover(String source, String luid)
throws IOException
{
lib.setSourceCover(source, luid);
cacheLib.setSourceCover(source, getCover(luid));
}
@Override
lib.setSourceCover(source, luid);
cacheLib.setSourceCover(source, getCover(luid));
}
@Override
- public void setAuthorCover(String author, String luid) {
+ public void setAuthorCover(String author, String luid)
throws IOException
{
lib.setAuthorCover(author, luid);
cacheLib.setAuthorCover(author, getCover(luid));
}
@Override
lib.setAuthorCover(author, luid);
cacheLib.setAuthorCover(author, getCover(luid));
}
@Override
- protected void updateInfo(MetaData meta) {
+ protected void updateInfo(MetaData meta)
throws IOException
{
if (meta != null && metas != null) {
if (meta != null && metas != null) {
+ boolean changed = false;
for (int i = 0; i < metas.size(); i++) {
if (metas.get(i).getLuid().equals(meta.getLuid())) {
metas.set(i, meta);
for (int i = 0; i < metas.size(); i++) {
if (metas.get(i).getLuid().equals(meta.getLuid())) {
metas.set(i, meta);
+ changed = true;
}
}
}
}
+
+ if (!changed) {
+ metas.add(meta);
+ }
}
cacheLib.updateInfo(meta);
}
cacheLib.updateInfo(meta);
@@
-317,7
+325,11
@@
public class CacheLibrary extends BasicLibrary {
* @return TRUE if it is
*/
public boolean isCached(String luid) {
* @return TRUE if it is
*/
public boolean isCached(String luid) {
- return cacheLib.getInfo(luid) != null;
+ try {
+ return cacheLib.getInfo(luid) != null;
+ } catch (IOException e) {
+ return false;
+ }
}
/**
}
/**
@@
-339,7
+351,7
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- public
Story
imprt(URL url, Progress pg) throws IOException {
+ public
MetaData
imprt(URL url, Progress pg) throws IOException {
if (pg == null) {
pg = new Progress();
}
if (pg == null) {
pg = new Progress();
}
@@
-350,13
+362,13
@@
public class CacheLibrary extends BasicLibrary {
pg.addProgress(pgImprt, 7);
pg.addProgress(pgCache, 3);
pg.addProgress(pgImprt, 7);
pg.addProgress(pgCache, 3);
-
Story story
= lib.imprt(url, pgImprt);
-
cacheLib.save(story, story.getMeta().getLuid(), pgCache
);
-
-
updateInfo(story.getMeta
());
-
+
MetaData meta
= lib.imprt(url, pgImprt);
+
updateInfo(meta
);
+
+
clearFromCache(meta.getLuid
());
+
pg.done();
pg.done();
- return
story
;
+ return
meta
;
}
// All the following methods are only used by Save and Delete in
}
// All the following methods are only used by Save and Delete in