Multiple old copies of recently-used.xbel under $HOME/.local/share

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
brancalessio
Level 2
Level 2
Posts: 97
Joined: Fri Jul 24, 2015 4:59 am

Multiple old copies of recently-used.xbel under $HOME/.local/share

Post by brancalessio »

Hello everyone!

I have this (small) issue in Linux Mint 21.1 Vera with MATE.

I found that under $HOME/.local/share there are several files named something like recently-used.xbel.PKFI61. They are old copies of recently-used.xbel and are not deleted when the list of recent files and applications is deleted in MATE. They have to be deleted manually.

Is there a way to avoid that MATE creates these files?

Thank you for your answer!
Last edited by LockBot on Wed Jan 24, 2024 11:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gtker
Level 1
Level 1
Posts: 2
Joined: Sun Jan 14, 2024 1:36 pm

Re: Multiple old copies of recently-used.xbel under $HOME/.local/share

Post by gtker »

Interesting, I'm experiencing exactly this under Debian 13 + xfce4. So I guess the problem lies in low-level details, maybe its even GtkRecentManager behaviour.
gtker
Level 1
Level 1
Posts: 2
Joined: Sun Jan 14, 2024 1:36 pm

Re: Multiple old copies of recently-used.xbel under $HOME/.local/share

Post by gtker »

I think we need to live with this.
GtkRecentManager is as simple (and bad) as possible in terms of storage technology. It heavily relies on glib for bookmark file (actually in-memory structure) and its serialization function. All it can do is to maintain single global recently-used.xbel on disk for all applications. When app flushes its internal bookmark view to disk, GtkRecentManager relies on glib_file_set_contents(), which does the following:
1. Create temporary recently-used.xbel.XXXXXX (with 0666 mode :D, but its irrelevant since .local/share should be 0700 anyway) and fallocate() it.
2. Copy its internal serialized bookmark file into temporary and do fsync() (slow!) on it.
3. rename() recently-used.xbel.XXXXXX -> recently-used.xbel
4. Do flush() on .local/share (maybe slow).
Thats how atomicity implemented.
Of course your program can be terminated between (1) and (3), so temporary file would be left on disk forever, no one will take responsibility for it.
Its bad that we can left in such situation, esp. when fsync() is slow (such filesystem or just HDD).
But its even worse that we are writing entire bookmark file on every flush.
Also we can lose our bookmarks easily, imagine that applications A and B both want to flush their bookmarks simultaneously. 'A' state is <prev state> + foo.odt. 'B' state is <prev state> + bar.jpg.
We can end up with <prev state> + foo.odt OR <prev state> + bar.jpg easily, but we want <prev state> + foo.odt + bar.jpg.
Locked

Return to “MATE”