diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-04-03 15:26:26 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-04-03 15:26:26 -0700 |
commit | 62c59820cf21d35f97d79bd75c946cfd282be5b8 (patch) | |
tree | 1373698380b08ebff31dad91b5213a2fbc58bcb2 /launcher/ui | |
parent | 5ce7874280f648e1db240ad922a2e62a7ccedea2 (diff) | |
download | PrismLauncher-62c59820cf21d35f97d79bd75c946cfd282be5b8.tar.gz PrismLauncher-62c59820cf21d35f97d79bd75c946cfd282be5b8.tar.bz2 PrismLauncher-62c59820cf21d35f97d79bd75c946cfd282be5b8.zip |
fix: harden watchPath. NO DUPLICATES! >:(
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/dialogs/BlockedModsDialog.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index 90078a98..e7404f2d 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -192,16 +192,19 @@ void BlockedModsDialog::setupWatch() void BlockedModsDialog::watchPath(QString path, bool watch_subdirectories) { - if (m_watcher.directories().contains(path)) + auto to_watch = QFileInfo(path); + auto to_watch_path = to_watch.canonicalPath(); + if (m_watcher.directories().contains(to_watch_path)) return; // don't watch the same path twice (no loops!) qDebug() << "[Blocked Mods Dialog] Adding Watch Path:" << path; - m_watcher.addPath(path); + m_watcher.addPath(to_watch_path); - if (!watch_subdirectories) + if (!to_watch.isDir() || !watch_subdirectories) return; - QDirIterator it(path, QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot, QDirIterator::NoIteratorFlags); + + QDirIterator it(to_watch_path, QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot, QDirIterator::NoIteratorFlags); while (it.hasNext()) { QString watch_dir = QDir(it.next()).canonicalPath(); // resolve symlinks and relative paths watchPath(watch_dir, watch_subdirectories); |