Trash spec: caching the size of the trash directory
David Faure
faure at kde.org
Thu Aug 13 13:17:50 PDT 2009
In order to implement the long-requested feature "automatically remove
the oldest (or biggest) items from the trash when it reaches a certain size",
we have the problem of constantly having to determine the size of the trash
(i.e. the size of the N trash directories).
This is really easy to solve with a cache (the value written into a file)
if we can agree to put that into the spec, so that all implementations of the
trash spec update that cached size value.
In order to keep that file out of the way of the info and files subdirs, I
suggest to put it at the same level as those two, i.e. at the root of each
trash directory.
The file could be named "metadata" (generic name so that we can add
more such info later), and I would suggest an INI format, much like
the trash info files.
[Cached]
Size=130460
(in bytes of course).
The group name indicates clearly that this is a cache, i.e. if it's not there
it can always be calculated the slow way -- but the goal is to not have
to do the recursive directory listing before each trash operation, that's
just too slow.
And then it's up to implementations to update that value, when
adding a file to the trash, restoring a trashed file, deleting a trashed file,
and when emptying the trash.
Is this OK with other implementors of the trash spec? Can it be added
to the spec?
--
David Faure, faure at kde.org, sponsored by Qt Software @ Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the xdg
mailing list