@Override
  public void deleteBook(String fileName) {
    this.helper.delete(fileName);

    // Only delete files we manage
    if (fileName.startsWith(config.getLibraryFolder())) {
      File bookFile = new File(fileName);
      File parentFolder = bookFile.getParentFile();

      bookFile.delete();

      while (parentFolder.list() == null || parentFolder.list().length == 0) {
        parentFolder.delete();
        parentFolder = parentFolder.getParentFile();
      }
    }
  }
  private File copyToLibrary(String fileName, String author, String title) throws IOException {

    File baseFile = new File(fileName);

    File targetFolder =
        new File(config.getLibraryFolder() + "/" + cleanUp(author) + "/" + cleanUp(title));

    targetFolder.mkdirs();

    FileChannel source = null;
    FileChannel destination = null;

    File targetFile = new File(targetFolder, baseFile.getName());

    if (baseFile.equals(targetFile)) {
      return baseFile;
    }

    LOG.debug("Copying to file: " + targetFile.getAbsolutePath());

    targetFile.createNewFile();

    try {
      source = new FileInputStream(baseFile).getChannel();
      destination = new FileOutputStream(targetFile).getChannel();
      destination.transferFrom(source, 0, source.size());
    } finally {
      if (source != null) {
        source.close();
      }
      if (destination != null) {
        destination.close();
      }
    }

    return targetFile;
  }