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

            Bug ID: 438527
           Summary: `balooctl clear` always prints "File(s) cleared" and
                    never prints "File not found on filesystem or in DB"
           Product: frameworks-baloo
           Version: 5.82.0
          Platform: Fedora RPMs
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: balooctl
          Assignee: baloo-bugs-n...@kde.org
          Reporter: skierp...@gmail.com
  Target Milestone: ---

SUMMARY
balooctl clear's logic seems wrong. If you clear a file that has never existed,
it prints "File(s) cleared" and never triggers its code that prints "File not
found on filesystem or in DB"

STEPS TO REPRODUCE
1. Enter `balooctl clear /never/had/this/file`
2. Enter `ls -lt $HOME/.local/share/baloo/index`
3. Look at baloo source code

OBSERVED RESULT
balooctl prints
  Could not stat file: /never/had/this/file
  File(s) cleared
The modification time of Baloo's index doesn't change.

EXPECTED RESULT
balooctl clear has code to print "File not found on filesystem or in DB" but it
doesn't run.
balooctl should print "NN file(s) cleared" where NN is the count of files
balooctl tried to clear from the index.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.21.5
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2 on Wayland

ADDITIONAL INFORMATION
The "clear" handling in
https://invent.kde.org/frameworks/baloo/-/blob/master/src/tools/balooctl/main.cpp
(which seems more recent than Fedora 34's package)
* assumes filePathToId() returning 0 means failure, but as I understand it the
underlying stat64() call returns 0 on _success_! -1 means error.
* always calls tr.removeDocument(id) for each argument even if it didn't locate
an id.
* always prints "File(s) cleared".
Baloo's removeDocument() doesn't return a status, so it seems impossible to
detect successful clearing.

It would also be nice to print the ID (as shown by balooshow and baloosearch
--id) of each file that was cleared in baloo's index, because of bug 438382 and
similar. So the ideal output from
  % balooctl clear /never/had/this/file /path/to/file2 /now/gone/file3
would be
  File /never/had/this/file not found in filesystem or in index.
  Clearing /path/to/file2 with ID 5be2000000803 from index.
  File /now/gone/file3 with ID 3fef80000fd03 not found in filesystem, clearing
from index.
  2 file(s) cleared from Baloo's index.

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

Reply via email to