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:
parent
6f4345aa2a
commit
2dd0c1bedd
1 changed files with 10 additions and 18 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue