mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Properly create "clean path" for watched folder
This commit is contained in:
parent
ede42910da
commit
3ac8c97e6f
2 changed files with 9 additions and 12 deletions
|
@ -267,11 +267,10 @@ QString TorrentFilesWatcher::makeCleanPath(const QString &path)
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
throw InvalidArgument(tr("Watched folder path cannot be empty."));
|
throw InvalidArgument(tr("Watched folder path cannot be empty."));
|
||||||
|
|
||||||
const QDir dir {path};
|
if (QDir::isRelativePath(path))
|
||||||
if (dir.isRelative())
|
|
||||||
throw InvalidArgument(tr("Watched folder path cannot be relative."));
|
throw InvalidArgument(tr("Watched folder path cannot be relative."));
|
||||||
|
|
||||||
return dir.canonicalPath();
|
return QDir::cleanPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentFilesWatcher::load()
|
void TorrentFilesWatcher::load()
|
||||||
|
|
|
@ -102,23 +102,21 @@ bool WatchedFoldersModel::removeRows(const int row, const int count, const QMode
|
||||||
|
|
||||||
void WatchedFoldersModel::addFolder(const QString &path, const TorrentFilesWatcher::WatchedFolderOptions &options)
|
void WatchedFoldersModel::addFolder(const QString &path, const TorrentFilesWatcher::WatchedFolderOptions &options)
|
||||||
{
|
{
|
||||||
if (path.isEmpty())
|
const QString cleanWatchPath = m_fsWatcher->makeCleanPath(path);
|
||||||
throw InvalidArgument(tr("Watched folder path cannot be empty."));
|
if (m_watchedFoldersOptions.contains(cleanWatchPath))
|
||||||
|
|
||||||
const QDir watchDir {path};
|
|
||||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
|
||||||
if (m_watchedFoldersOptions.contains(canonicalWatchPath))
|
|
||||||
throw RuntimeError(tr("Folder '%1' is already in watch list.").arg(path));
|
throw RuntimeError(tr("Folder '%1' is already in watch list.").arg(path));
|
||||||
|
|
||||||
|
const QDir watchDir {cleanWatchPath};
|
||||||
if (!watchDir.exists())
|
if (!watchDir.exists())
|
||||||
throw RuntimeError(tr("Folder '%1' doesn't exist.").arg(path));
|
throw RuntimeError(tr("Folder '%1' doesn't exist.").arg(path));
|
||||||
if (!watchDir.isReadable())
|
if (!watchDir.isReadable())
|
||||||
throw RuntimeError(tr("Folder '%1' isn't readable.").arg(path));
|
throw RuntimeError(tr("Folder '%1' isn't readable.").arg(path));
|
||||||
|
|
||||||
m_deletedFolders.remove(canonicalWatchPath);
|
m_deletedFolders.remove(cleanWatchPath);
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
m_watchedFolders.append(canonicalWatchPath);
|
m_watchedFolders.append(cleanWatchPath);
|
||||||
m_watchedFoldersOptions[canonicalWatchPath] = options;
|
m_watchedFoldersOptions[cleanWatchPath] = options;
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue