Bug 422189 - kf5.kio.trash stats thousands of files in ~/.local/share/Trash/files
Summary: kf5.kio.trash stats thousands of files in ~/.local/share/Trash/files
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Trash (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-28 16:13 UTC by Björn Lindqvist
Modified: 2020-06-16 08:59 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.72


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Lindqvist 2020-05-28 16:13:18 UTC
I have thousands of errors like these in my system log:

kdeinit5[5195]: kf5.kio.trash: couldn't stat  "/home/bjourne/.local/share/Trash/files/generator.m"
kdeinit5[28666]: kf5.kio.trash: couldn't stat  "/home/bjourne/.local/share/Trash/files/svt"

These are files I deleted months or even years ago the old fashioned way using rm .local/share/Trash/* so I don't understand why KDE keeps a record of them. 

Since it sometimes tries to stat thousands of files per second it completely freezes my computer for the duration.
Comment 1 Ahmad Samir 2020-06-02 13:26:54 UTC
The records are kept because IIUC users are supposed to be able to restore deleted files from the Trash.

Examine ~/.local/share/Trash/info/* and ~/.local/share/Trash/directorysizes

I don't think this is a bug, you basically deleted the files in the Trash, without telling kio_trash about it... :)
Comment 2 Méven Car 2020-06-02 14:00:52 UTC
(In reply to Ahmad Samir from comment #1)
> The records are kept because IIUC users are supposed to be able to restore
> deleted files from the Trash.

Exact

> 
> Examine ~/.local/share/Trash/info/* and ~/.local/share/Trash/directorysizes
> 
> I don't think this is a bug, you basically deleted the files in the Trash,
> without telling kio_trash about it... :)

Still we tru to dectect orhpaned files such as here where we have the metadata but not the files. Your bug shows it does not clean its record, once it has noticed the files are orphaned, since this repeats or at least not correctly.
Comment 3 Ahmad Samir 2020-06-02 14:08:59 UTC
(In reply to Méven Car from comment #2)
[..]
> 
> Still we tru to dectect orhpaned files such as here where we have the
> metadata but not the files. Your bug shows it does not clean its record,
> once it has noticed the files are orphaned, since this repeats or at least
> not correctly.

Good point, non-existing files should indeed be removed from the Trash records/info.
Comment 4 Méven Car 2020-06-16 08:59:24 UTC
Git commit 73cc5a82de887b197ddfd35e0dce3d1a34d5eb47 by Méven Car, on behalf of Ahmad Samir.
Committed on 16/06/2020 at 08:59.
Pushed by meven into branch 'master'.

[Trash] Remove trashinfo files referencing files/dirs that don't exist

If the user moves a file to trash, the deletes that file without using
kio_trash (e.g. with rm), then the relevant trashinfo file should be
deleted the next time we try to list/stat that trashed file; otherwise
kio_trash keep trying to stat that file every time the Trash dir is
stat'ed/listed.

The testtrash unit test still passes.

Thanks to meven for pointing out how to fix this bug.
FIXED-IN: 5.72

M  +2    -1    src/ioslaves/trash/kio_trash.cpp
M  +24   -0    src/ioslaves/trash/tests/testtrash.cpp
M  +1    -0    src/ioslaves/trash/tests/testtrash.h

https://invent.kde.org/frameworks/kio/commit/73cc5a82de887b197ddfd35e0dce3d1a34d5eb47