Example #1
0
  public static Book getByFile(ZLFile bookFile) {
    if (bookFile == null) {
      return null;
    }

    final ZLPhysicalFile physicalFile = bookFile.getPhysicalFile();
    if (physicalFile != null && !physicalFile.exists()) {
      return null;
    }

    final FileInfoSet fileInfos = new FileInfoSet(bookFile);

    Book book = BooksDatabase.Instance().loadBookByFile(fileInfos.getId(bookFile), bookFile);
    if (book != null) {
      book.loadLists();
    }

    if (book != null && fileInfos.check(physicalFile, physicalFile != bookFile)) {
      return book;
    }
    fileInfos.save();

    if (book == null) {
      book = new Book(bookFile);
    }
    if (book.readMetaInfo()) {
      book.save();
      return book;
    }
    return null;
  }
  public boolean saveBook(Book book, boolean force) {
    if (book == null) {
      return false;
    }

    final boolean result = book.save(myDatabase, force);
    addBook(book, true);
    return result;
  }