git://git.nikiroo.be
/
fanfix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
678390e
)
Remote: fix missing cover (try 1)
author
Niki Roo
<niki@nikiroo.be>
Fri, 10 Aug 2018 15:33:40 +0000
(17:33 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Fri, 10 Aug 2018 15:33:40 +0000
(17:33 +0200)
src/be/nikiroo/fanfix/library/BasicLibrary.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/library/CacheLibrary.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/library/LocalLibrary.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/library/RemoteLibrary.java
patch
|
blob
|
blame
|
history
diff --git
a/src/be/nikiroo/fanfix/library/BasicLibrary.java
b/src/be/nikiroo/fanfix/library/BasicLibrary.java
index 350a8cafcc6ecc4ff2eafba768e052fe323db122..206e80f360dfcb82927cbec0eb7762b2b652c05e 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/BasicLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/BasicLibrary.java
@@
-135,19
+135,29
@@
abstract public class BasicLibrary {
* Invalidate the {@link Story} cache (when the content should be re-read
* because it was changed).
*/
* Invalidate the {@link Story} cache (when the content should be re-read
* because it was changed).
*/
- protected void
invalida
teInfo() {
-
invalida
teInfo(null);
+ protected void
dele
teInfo() {
+
dele
teInfo(null);
}
/**
}
/**
- * Invalidate the {@link Story} cache (when the content should be re-read
- * because it was changed).
+ * Invalidate the {@link Story} cache (when the content is removed).
+ * <p>
+ * All the cache can be deleted if NULL is passed as meta.
*
* @param luid
*
* @param luid
- * the
luid
of the {@link Story} to clear from the cache, or NULL
+ * the
LUID
of the {@link Story} to clear from the cache, or NULL
* for all stories
*/
* for all stories
*/
- protected abstract void invalidateInfo(String luid);
+ protected abstract void deleteInfo(String luid);
+
+ /**
+ * Invalidate the {@link Story} cache (when the content has changed, but we
+ * already have it) with the new given meta.
+ *
+ * @param meta
+ * the {@link Story} to clear from the cache
+ */
+ protected abstract void updateInfo(MetaData meta);
/**
* Return the next LUID that can be used.
/**
* Return the next LUID that can be used.
@@
-521,9
+531,9
@@
abstract public class BasicLibrary {
delete(luid);
}
delete(luid);
}
- doSave(story, pg);
+
story =
doSave(story, pg);
-
invalidateInfo(luid
);
+
updateInfo(story.getMeta()
);
return story;
}
return story;
}
@@
-539,7
+549,7
@@
abstract public class BasicLibrary {
*/
public synchronized void delete(String luid) throws IOException {
doDelete(luid);
*/
public synchronized void delete(String luid) throws IOException {
doDelete(luid);
-
invalida
teInfo(luid);
+
dele
teInfo(luid);
}
/**
}
/**
diff --git
a/src/be/nikiroo/fanfix/library/CacheLibrary.java
b/src/be/nikiroo/fanfix/library/CacheLibrary.java
index ee22e3439cc6d38001b6c36885106641fba0112a..ee2db3f6ce75371f1ab6bd5ec6468f2a9f984155 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/CacheLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/CacheLibrary.java
@@
-83,8
+83,8
@@
public class CacheLibrary extends BasicLibrary {
if (!isCached(luid)) {
try {
cacheLib.imprt(lib, luid, pgImport);
if (!isCached(luid)) {
try {
cacheLib.imprt(lib, luid, pgImport);
+ updateInfo(cacheLib.getInfo(luid));
pgImport.done();
pgImport.done();
- invalidateInfo(luid);
} catch (IOException e) {
Instance.getTraceHandler().error(e);
}
} catch (IOException e) {
Instance.getTraceHandler().error(e);
}
@@
-123,24
+123,33
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- protected void invalidateInfo(String luid) {
+ protected void updateInfo(MetaData meta) {
+ if (meta != null) {
+ for (int i = 0; i < metas.size(); i++) {
+ if (metas.get(i).getLuid().equals(meta.getLuid())) {
+ metas.set(i, meta);
+ }
+ }
+ }
+
+ cacheLib.updateInfo(meta);
+ lib.updateInfo(meta);
+ }
+
+ @Override
+ protected void deleteInfo(String luid) {
if (luid == null) {
metas = null;
} else if (metas != null) {
if (luid == null) {
metas = null;
} else if (metas != null) {
- MetaData meta = lib.getInfo(luid);
for (int i = 0; i < metas.size(); i++) {
if (metas.get(i).getLuid().equals(luid)) {
metas.remove(i--);
}
}
for (int i = 0; i < metas.size(); i++) {
if (metas.get(i).getLuid().equals(luid)) {
metas.remove(i--);
}
}
-
- if (meta != null) {
- metas.add(meta);
- }
}
}
- cacheLib.
invalida
teInfo(luid);
- lib.
invalida
teInfo(luid);
+ cacheLib.
dele
teInfo(luid);
+ lib.
dele
teInfo(luid);
}
@Override
}
@Override
@@
-160,7
+169,7
@@
public class CacheLibrary extends BasicLibrary {
story = lib.save(story, luid, pgLib);
story = cacheLib.save(story, story.getMeta().getLuid(), pgCacheLib);
story = lib.save(story, luid, pgLib);
story = cacheLib.save(story, story.getMeta().getLuid(), pgCacheLib);
-
invalidateInfo(story.getMeta().getLuid
());
+
updateInfo(story.getMeta
());
return story;
}
return story;
}
@@
-233,7
+242,7
@@
public class CacheLibrary extends BasicLibrary {
public void clearFromCache(String luid) throws IOException {
if (isCached(luid)) {
cacheLib.delete(luid);
public void clearFromCache(String luid) throws IOException {
if (isCached(luid)) {
cacheLib.delete(luid);
-
invalida
teInfo(luid);
+
dele
teInfo(luid);
}
}
}
}
@@
-252,7
+261,7
@@
public class CacheLibrary extends BasicLibrary {
Story story = lib.imprt(url, pgImprt);
cacheLib.save(story, story.getMeta().getLuid(), pgCache);
Story story = lib.imprt(url, pgImprt);
cacheLib.save(story, story.getMeta().getLuid(), pgCache);
-
invalidateInfo(story.getMeta().getLuid
());
+
updateInfo(story.getMeta
());
pg.done();
return story;
pg.done();
return story;
diff --git
a/src/be/nikiroo/fanfix/library/LocalLibrary.java
b/src/be/nikiroo/fanfix/library/LocalLibrary.java
index 275926cd93164788258381b094fcef594cde7bbf..54ad1d66769d8962cf5516a2bc5c6302e04e0ac6 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/LocalLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/LocalLibrary.java
@@
-127,7
+127,12
@@
public class LocalLibrary extends BasicLibrary {
}
@Override
}
@Override
- protected synchronized void invalidateInfo(String luid) {
+ protected synchronized void updateInfo(MetaData meta) {
+ deleteInfo();
+ }
+
+ @Override
+ protected void deleteInfo(String luid) {
stories = null;
sourceCovers = new HashMap<String, Image>();
}
stories = null;
sourceCovers = new HashMap<String, Image>();
}
@@
-189,7
+194,7
@@
public class LocalLibrary extends BasicLibrary {
}
}
}
}
-
invalida
teInfo();
+
dele
teInfo();
}
@Override
}
@Override
@@
-261,7
+266,7
@@
public class LocalLibrary extends BasicLibrary {
pg.add(1);
}
pg.add(1);
}
-
invalida
teInfo();
+
dele
teInfo();
pg.done();
return;
}
pg.done();
return;
}
@@
-269,7
+274,7
@@
public class LocalLibrary extends BasicLibrary {
super.imprt(other, luid, pg);
super.imprt(other, luid, pg);
-
invalida
teInfo();
+
dele
teInfo();
}
/**
}
/**
@@
-404,7
+409,7
@@
public class LocalLibrary extends BasicLibrary {
* {@link LocalLibrary#baseDir}.
* <p>
* Will use a cached list when possible (see
* {@link LocalLibrary#baseDir}.
* <p>
* Will use a cached list when possible (see
- * {@link BasicLibrary#
invalida
teInfo()}).
+ * {@link BasicLibrary#
dele
teInfo()}).
*
* @param pg
* the optional {@link Progress}
*
* @param pg
* the optional {@link Progress}
diff --git
a/src/be/nikiroo/fanfix/library/RemoteLibrary.java
b/src/be/nikiroo/fanfix/library/RemoteLibrary.java
index 5052fa279dd4cdcbe127a61edd8f2a00ca4bf9a6..44d39adbcc30d8b6867aaf5fd4961ac0dc00bac9 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/RemoteLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/RemoteLibrary.java
@@
-233,10
+233,14
@@
public class RemoteLibrary extends BasicLibrary {
}.connect();
// because the meta changed:
}.connect();
// because the meta changed:
- invalidateInfo(luidSaved[0]);
-
MetaData meta = getInfo(luidSaved[0]);
MetaData meta = getInfo(luidSaved[0]);
- meta.setCover(story.getMeta().getCover());
+ if (story.getMeta().getClass() != null) {
+ // If already available locally:
+ meta.setCover(story.getMeta().getCover());
+ } else {
+ // If required:
+ meta.setCover(getCover(meta.getLuid()));
+ }
story.setMeta(meta);
pg.done();
story.setMeta(meta);
pg.done();
@@
-411,7
+415,13
@@
public class RemoteLibrary extends BasicLibrary {
}
@Override
}
@Override
- protected void invalidateInfo(String luid) {
+ protected void updateInfo(MetaData meta) {
+ // Will be taken care of directly server side
+ }
+
+ @Override
+ protected void deleteInfo(String luid) {
+ // Will be taken care of directly server side
}
// The following methods are only used by Save and Delete in BasicLibrary:
}
// The following methods are only used by Save and Delete in BasicLibrary: