private void handleCoreDownloader() { File possibleTorrentFile = null; possibleTorrentFile = downloader.getSaveFile(); String fileExtension = FileUtils.getFileExtension(possibleTorrentFile); if ("torrent".equalsIgnoreCase(fileExtension)) { try { shareTorrentFile(possibleTorrentFile); downloadManager.downloadTorrent(possibleTorrentFile, null, false); downloadItems.remove(getDownloadItem(downloader)); } catch (DownloadException e) { final File torrentFile = possibleTorrentFile; activityCallback.handleDownloadException( new DownloadAction() { @Override public void download(File saveDirectory, boolean overwrite) throws DownloadException { downloadManager.downloadTorrent(torrentFile, saveDirectory, overwrite); downloadItems.remove(getDownloadItem(downloader)); } @Override public void downloadCanceled(DownloadException ignored) { // nothing to do } }, e, false); } } }
private void handleBTTorrentFileDownloader() { File torrentFile = null; final BTTorrentFileDownloader btTorrentFileDownloader = (BTTorrentFileDownloader) downloader; try { torrentFile = btTorrentFileDownloader.getTorrentFile(); shareTorrentFile(torrentFile); downloadManager.downloadTorrent(torrentFile, null, false); downloadItems.remove(getDownloadItem(downloader)); } catch (DownloadException e) { final File torrentFileFinal = torrentFile; activityCallback.handleDownloadException( new DownloadAction() { @Override public void download(File saveDirectory, boolean overwrite) throws DownloadException { downloadManager.downloadTorrent(torrentFileFinal, saveDirectory, overwrite); downloadItems.remove(getDownloadItem(downloader)); } @Override public void downloadCanceled(DownloadException ex) { if (!torrentManager.isDownloadingTorrent(torrentFileFinal)) { // need to delete to clean up the torrent file in the // incomplete directory FileUtils.forceDelete(torrentFileFinal); } } }, e, false); } }