https://bugs.kde.org/show_bug.cgi?id=435161

--- Comment #7 from Bernie Innocenti <ber...@codewiz.org> ---
I don't see how these asserts could have ever worked in the past. I traced back
the pathnames, and the '/' is appended to all directories with
normalizeTrailingSlash():
https://invent.kde.org/frameworks/baloo/-/blob/master/src/file/kinotify.cpp#L359

So, new directories will always have a trailing slash, why is
NewFileIndexer::run() not expecting to see them?
My first hypothesis was that NewFileIndex is only for processing files. But
there's a specific check for directories a few lines after the Q_ASSERT that
fails:
​https://invent.kde.org/frameworks/baloo/-/blob/master/src/file/newfileindexer.cpp#L47-51

Code to append slashes to directories was added ~1 year ago:
https://invent.kde.org/frameworks/baloo/-/commit/73183acf00a2b7f10b286a1241716cb7e0785f0d

A few months later, we removed a couple of asserts on directory removal and
rename:
https://invent.kde.org/frameworks/baloo/-/commit/96284739b4b63110113af0ba7dedfd18c4459063

The second check was missing a '!', and it was added shortly after by Nate:
https://invent.kde.org/frameworks/baloo/-/commit/dc04879f058dd1eab72e4bd4c80bdc1ea3c06c9b

So I think we missed directory creation and a few other cases. It should be
safe to keep trailing slashes, because BasicIndexingJob strips them in the
constructor:
https://invent.kde.org/frameworks/baloo/-/blob/master/src/file/basicindexingjob.cpp#L26-28

There are other asserts disallowing trailing slashes. These are placed just
before code like this:
  QString fileName = filePath.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1);

So I think we can't simply remove the check, as it will set fileName to an
empty string. QFileInfo::fileName() is explicitly documented to behave like
this:
  "Note that, if this QFileInfo object is given a path ending in a slash, the
name of the file is considered empty."

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to