git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
try +1
[fanfix.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 26204156b4d587cb7353851de1a8ea8af7e12b84..a9063308f8faf2ca0741c22b0e2cb21ea198ef96 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,31
+123,33
@@
public class CacheLibrary extends BasicLibrary {
}
@Override
}
@Override
- protected void invalidateInfo(String luid) {
- List<MetaData> metas = this.metas;
+ protected void updateInfo(MetaData meta) {
+ if (meta != null && metas != 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) {
if (luid == null) {
-
this.
metas = null;
+ metas = null;
} else if (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)) {
for (int i = 0; i < metas.size(); i++) {
if (metas.get(i).getLuid().equals(luid)) {
- if (meta != null) {
- metas.set(i, meta);
- meta = null;
- } else {
- metas.remove(i--);
- }
+ 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
@@
-167,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;
}
@@
-179,13
+181,9
@@
public class CacheLibrary extends BasicLibrary {
}
lib.delete(luid);
}
lib.delete(luid);
- List<MetaData> metas = this.metas;
- if (metas != null) {
- for (int i = 0; i < metas.size(); i++) {
- if (metas.get(i).getLuid().equals(luid)) {
- metas.set(i, lib.getInfo(luid));
- }
- }
+ MetaData meta = getInfo(luid);
+ if (meta != null) {
+ metas.remove(meta);
}
}
}
}
@@
-244,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);
}
}
}
}
@@
-263,6
+261,8
@@
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);
+ updateInfo(story.getMeta());
+
pg.done();
return story;
}
pg.done();
return story;
}