From 4f8155e612d3adb19955a27d130274ff8bb4b1a8 Mon Sep 17 00:00:00 2001 From: "Artem S. Tashkinov" Date: Tue, 3 Mar 2015 00:22:45 +0500 Subject: [PATCH] Let's check if the torrent file can actually be opened before passing it to libtorrent If we don't have enough permissions, libtorrent will spew a pretty useless, irrelevant and almost wrong message: "Failed to load the torrent: torrent file is not a dictionary" --- src/gui/addnewtorrentdialog.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index e480ae38b..afb780b0d 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -190,6 +190,12 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString return false; } + QFileInfo fileinfo(m_filePath); + if (!fileinfo.isReadable()) { + MessageBoxRaised::critical(0, tr("I/O Error"), tr("The torrent file cannot be read from the disk. Probably you don't have enough permissions.")); + return false; + } + m_hasMetadata = true; try {