docs: @Override
    public void finish() throws IOException {
      try {
        myLock.writeLock().lock();
        logger.debug("Closing file channel to " + this.current.getName() +
                " (download complete).");
        if (this.channel.isOpen()) {
          this.channel.force(true);
        }
  
        // Nothing more to do if we're already on the target file.
        if (this.isFinished()) {
          return;
        }
  
        try {
          FileUtils.deleteQuietly(this.target);
          this.raf.close();
          FileUtils.moveFile(this.current, this.target);
        } catch (Exception ex) {
          logger.error("An error occurred while moving file to its final location", ex);
          if (this.target.exists()) {
            throw new IOException("Was unable to delete existing file " + target.getAbsolutePath(), ex);
          }
          FileUtils.copyFile(this.current, this.target);
        }
  
        this.current = this.target;
  
        FileUtils.deleteQuietly(this.partial);
        myIsOpen = false;
        logger.debug("Moved torrent data from {} to {}.",
                this.partial.getName(),
                this.target.getName());
      } finally {
        myLock.writeLock().unlock();
      }
    }