Skip to content

Commit

Permalink
io/fileview: ensure directory is watched for file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed committed Feb 20, 2025
1 parent aeb347b commit 1eabf5b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/io/fileview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,14 @@ void FileView::updateWatchedFiles() {
qCDebug(logFileView) << "Creating watcher for" << this << "at" << this->targetPath;
this->watcher = new QFileSystemWatcher(this);
this->watcher->addPath(this->targetPath);
this->watcher->addPath(QDir(this->targetPath).dirName());

auto dirPath = this->targetPath;
if (!dirPath.contains("/")) dirPath = "./" % dirPath;

if (auto lastIndex = dirPath.lastIndexOf('/'); lastIndex != -1) {
dirPath = dirPath.sliced(0, lastIndex);
this->watcher->addPath(dirPath);
}

QObject::connect(
this->watcher,
Expand Down

0 comments on commit 1eabf5b

Please sign in to comment.