1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

fixed Book object creation

This commit is contained in:
Nikolay Pultsin 2013-04-08 06:23:24 +04:00
parent 6f4345aa2a
commit 2dd0c1bedd

View file

@ -174,7 +174,7 @@ public class BookCollection extends AbstractBookCollection {
}
}
public boolean saveBook(Book book, boolean force) {
public synchronized boolean saveBook(Book book, boolean force) {
if (book == null) {
return false;
}
@ -682,19 +682,14 @@ public class BookCollection extends AbstractBookCollection {
}
// Step 3: add help file
try {
final ZLFile helpFile = BookUtil.getHelpFile();
Book helpBook = savedBooksByFileId.get(fileInfos.getId(helpFile));
if (helpBook == null) {
helpBook = new Book(helpFile);
}
saveBook(helpBook, false);
// saved
addBook(helpBook, false);
} catch (BookReadingException e) {
// that's impossible
e.printStackTrace();
final ZLFile helpFile = BookUtil.getHelpFile();
Book helpBook = savedBooksByFileId.get(fileInfos.getId(helpFile));
if (helpBook == null) {
helpBook = getBookByFile(helpFile);
}
saveBook(helpBook, false);
// saved
addBook(helpBook, false);
// Step 4: save changes into database
fileInfos.save();
@ -774,12 +769,9 @@ public class BookCollection extends AbstractBookCollection {
);
}
} else {
try {
final Book book = new Book(file);
final Book book = getBookByFile(file);
if (book != null) {
newBooks.add(book);
return;
} catch (BookReadingException e) {
// ignore
}
}
}