[pacman-dev] [PATCH] Handle removal of empty directories properly

Dan McGee dpmcgee at gmail.com
Mon Jul 18 11:27:36 EDT 2011


On Sun, Jul 17, 2011 at 4:29 AM, Xavier Chantry
<chantry.xavier at gmail.com> wrote:
> On Sat, Jul 16, 2011 at 5:11 PM, Dan McGee <dan at archlinux.org> wrote:
>> This addresses FS#25141. We shouldn't remove every empty directory we
>> come across during the removal process unless it is truly not known to
>> any other package. This will prevent removal of essential directories
>> such as '/var/lock/'.
>>
>> This is accomplished by first checking the empty/non-empty status of a
>> directory, which was previously done implicitly by calling rmdir() and
>> ignoring errors. We do this to avoid the next (new) check in most cases,
>> which is to look at all local packages to see if the to-be-removed
>> directory is present in another packages' filelist. If we do not find it
>> anywhere, then we remove it, else we keep the file around.
>>
>
> I always thought pacman should do that, but Nagy concerns were
> obviously right, loading /var/lib/pacman/local/*/files takes time.
> This just highlights once more the poor design of the local db.
>
> pacman -R teeworlds goes from 2sec to 12sec here (after dropping caches)
Haha, I haven't done the "drop caches" checks in quite some time. I've
mostly conceded the fact that this will be slower, and it isn't all
that common. Did you run pacman-db-optimize first?

> ... and from 0.4sec to 0.7sec when everything is cached. But only a
> pacman -Qo 'orphaned_file' or a previous -R operation would load all
> /var/lib/pacman/local/*/files
Or the much more common case, which is an -S operation, where we
definitely load quite a few local filelists. Sure, not all of them,
but still a good chunk on an -Syu.

> Just to make myself clear, I think this patch should go in, and the
> local db out :)
> In the meantime, we have filesystem loops fortunately.
Yes, I feel like including something like this will make us take a
closer look at the local DB format in the future. Allan and I have
already looked into some things so we can do full package integrity
checking on the system (modes, sizes, checksums, etc.)

-Dan


More information about the pacman-dev mailing list