mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
Don't add the watch folder before the user closes the Preferences window.
This commit is contained in:
parent
56ca80eb78
commit
990e33a4b1
3 changed files with 20 additions and 4 deletions
|
@ -203,7 +203,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
|
|||
return true;
|
||||
}
|
||||
|
||||
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
|
||||
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath, bool addToFSWatcher)
|
||||
{
|
||||
QDir watchDir(watchPath);
|
||||
if (!watchDir.exists()) return DoesNotExist;
|
||||
|
@ -225,10 +225,23 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath,
|
|||
endInsertRows();
|
||||
|
||||
// Start scanning
|
||||
m_fsWatcher->addPath(canonicalWatchPath);
|
||||
if (addToFSWatcher)
|
||||
m_fsWatcher->addPath(canonicalWatchPath);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths)
|
||||
{
|
||||
if (!m_fsWatcher)
|
||||
return; // addPath() wasn't called before this
|
||||
|
||||
foreach (const QString &path, watchPaths) {
|
||||
QDir watchDir(path);
|
||||
const QString &canonicalWatchPath = watchDir.canonicalPath();
|
||||
m_fsWatcher->addPath(canonicalWatchPath);
|
||||
}
|
||||
}
|
||||
|
||||
void ScanFoldersModel::removePath(int row)
|
||||
{
|
||||
Q_ASSERT((row >= 0) && (row < rowCount()));
|
||||
|
|
|
@ -81,7 +81,9 @@ public:
|
|||
|
||||
// TODO: removePaths(); singular version becomes private helper functions;
|
||||
// also: remove functions should take modelindexes
|
||||
PathStatus addPath(const QString &watchPath, const PathType& downloadType, const QString &downloadPath);
|
||||
PathStatus addPath(const QString &watchPath, const PathType& downloadType, const QString &downloadPath, bool addToFSWatcher = true);
|
||||
// PRECONDITION: The paths must have been added with addPath() first.
|
||||
void addToFSWatcher(const QStringList &watchPaths);
|
||||
void removePath(int row);
|
||||
bool removePath(const QString &path);
|
||||
|
||||
|
|
|
@ -418,6 +418,7 @@ void options_imp::saveOptions()
|
|||
pref->useAdditionDialog(useAdditionDialog());
|
||||
pref->additionDialogFront(checkAdditionDialogFront->isChecked());
|
||||
pref->addTorrentsInPause(addTorrentsInPause());
|
||||
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
|
||||
ScanFoldersModel::instance()->makePersistent();
|
||||
addedScanDirs.clear();
|
||||
pref->setTorrentExportDir(getTorrentExportDir());
|
||||
|
@ -1203,7 +1204,7 @@ void options_imp::on_addScanFolderButton_clicked()
|
|||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
|
||||
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
||||
if (!dir.isEmpty()) {
|
||||
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, ScanFoldersModel::DOWNLOAD_IN_WATCH_FOLDER, QString());
|
||||
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, ScanFoldersModel::DOWNLOAD_IN_WATCH_FOLDER, QString(), false);
|
||||
QString error;
|
||||
switch (status) {
|
||||
case ScanFoldersModel::AlreadyInList:
|
||||
|
|
Loading…
Reference in a new issue