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
weblib: use more templats
[fanfix.git]
/
src
/
be
/
nikiroo
/
fanfix
/
library
/
LocalLibrary.java
diff --git
a/src/be/nikiroo/fanfix/library/LocalLibrary.java
b/src/be/nikiroo/fanfix/library/LocalLibrary.java
index 3cf5a25bc232baddd6ed34df9faabbaa3d82281f..f655d4d03bb43b5df69d00fc8b30b2adbad6c113 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/LocalLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/LocalLibrary.java
@@
-20,10
+20,10
@@
import be.nikiroo.fanfix.output.BasicOutput;
import be.nikiroo.fanfix.output.BasicOutput.OutputType;
import be.nikiroo.fanfix.output.InfoCover;
import be.nikiroo.fanfix.supported.InfoReader;
import be.nikiroo.fanfix.output.BasicOutput.OutputType;
import be.nikiroo.fanfix.output.InfoCover;
import be.nikiroo.fanfix.supported.InfoReader;
+import be.nikiroo.utils.HashUtils;
import be.nikiroo.utils.IOUtils;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.Progress;
import be.nikiroo.utils.IOUtils;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.Progress;
-import be.nikiroo.utils.StringUtils;
/**
* This {@link BasicLibrary} will store the stories locally on disk.
/**
* This {@link BasicLibrary} will store the stories locally on disk.
@@
-168,11
+168,11
@@
public class LocalLibrary extends BasicLibrary {
}
@Override
}
@Override
- protected
int
getNextId() {
+ protected
String
getNextId() {
getStories(null); // make sure lastId is set
synchronized (lock) {
getStories(null); // make sure lastId is set
synchronized (lock) {
- return
++lastId
;
+ return
String.format("%03d", ++lastId)
;
}
}
}
}
@@
-254,7
+254,13
@@
public class LocalLibrary extends BasicLibrary {
in = new FileInputStream(cover);
try {
synchronized (lock) {
in = new FileInputStream(cover);
try {
synchronized (lock) {
- sourceCovers.put(source, new Image(in));
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ sourceCovers.put(source, img);
}
} finally {
in.close();
}
} finally {
in.close();
@@
-298,7
+304,13
@@
public class LocalLibrary extends BasicLibrary {
in = new FileInputStream(cover);
try {
synchronized (lock) {
in = new FileInputStream(cover);
try {
synchronized (lock) {
- authorCovers.put(author, new Image(in));
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ authorCovers.put(author, img);
}
} finally {
in.close();
}
} finally {
in.close();
@@
-553,7
+565,7
@@
public class LocalLibrary extends BasicLibrary {
*/
private File getAuthorCoverFile(String author) {
File aDir = new File(baseDir, "_AUTHORS");
*/
private File getAuthorCoverFile(String author) {
File aDir = new File(baseDir, "_AUTHORS");
- String hash =
StringUtils.getMd5Hash
(author);
+ String hash =
HashUtils.md5
(author);
String ext = Instance.getInstance().getConfig()
.getString(Config.FILE_FORMAT_IMAGE_FORMAT_COVER);
return new File(aDir, hash + "." + ext.toLowerCase());
String ext = Instance.getInstance().getConfig()
.getString(Config.FILE_FORMAT_IMAGE_FORMAT_COVER);
return new File(aDir, hash + "." + ext.toLowerCase());
@@
-637,10
+649,13
@@
public class LocalLibrary extends BasicLibrary {
}
Map<MetaData, File[]> stories = this.stories;
}
Map<MetaData, File[]> stories = this.stories;
- synchronized (lock) {
- if (stories == null) {
- stories = getStoriesDo(pg);
- this.stories = stories;
+ if (stories == null) {
+ stories = getStoriesDo(pg);
+ synchronized (lock) {
+ if (this.stories == null)
+ this.stories = stories;
+ else
+ stories = this.stories;
}
}
}
}
@@
-715,10
+730,6
@@
public class LocalLibrary extends BasicLibrary {
}
for (File infoFileOrSubdir : infoFilesAndSubdirs) {
}
for (File infoFileOrSubdir : infoFilesAndSubdirs) {
- if (pgFiles != null) {
- pgFiles.setName(infoFileOrSubdir.getName());
- }
-
if (infoFileOrSubdir.isDirectory()) {
addToStories(stories, null, infoFileOrSubdir);
} else {
if (infoFileOrSubdir.isDirectory()) {
addToStories(stories, null, infoFileOrSubdir);
} else {