Bug 343735

Summary: user-places.xbel regularly gets overridden (so custom places disappear)
Product: [Plasma] plasmashell Reporter: Jiehong <email>
Component: generalAssignee: David Edmundson <kde>
Status: RESOLVED DUPLICATE    
Severity: major CC: andydecleyre, bhush94, emmanuelpescosta099, marco_silva85, notmart, simonandric5, xplwowi
Priority: NOR    
Version: 5.2.0   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Jiehong 2015-02-03 13:06:48 UTC
$HOME/.local/share/user-places.xbel gets overridden once in a while, by an unknown process

Reproducible: Always

Steps to Reproduce:
1. open Dolphin or Konqueror, and add a local place;
2. verify that $HOME/.local/share/user-places.xbel contains the directory you just added, and close Dolphin;
3. wait a moment (can vary), and see that its contain has been overridden (and the place has disappeared from Dolphin.

Actual Results:  
The content of user-places.xbel always gets overiden with the following default content:

<?xml version="1.0" encoding="UTF-8"?>                                                                                                                
<!DOCTYPE xbel>
<xbel xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info" xmlns:kdepriv="http://www.kde.org/kdepriv" xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"/>

Expected Results:  
user-places.xbel should not be overridden by any applications, unless a place is added/removed by the user.

In my last trial, it took 7 minutes for the file to be modified, and I was trying to know what happened at the time of modification of the file (permissions: -rw-r--r--) : 13:18:15 (local time).

$ journalctl -b --no-pager | grep -i '13\:18\:15'
Feb 03 13:18:15 laptop kwin_x11[658]: kwin_core: screens:  1 desktops:  2
Feb 03 13:18:15 laptop kwin_x11[658]: kwin_core: Done.
Feb 03 13:18:15 laptop kdeinit5[603]: Enabled: false
Feb 03 13:18:15 laptop kdeinit5[603]: Handler: 0
Feb 03 13:18:15 laptop kdeinit5[603]: Exclude: 0x0  Match?  false
Feb 03 13:18:15 laptop kdeinit5[603]: false
Feb 03 13:18:15 laptop kdeinit5[603]: Gesture ungrab
Feb 03 13:18:15 laptop kdeinit5[603]: Enabled: false
Feb 03 13:18:15 laptop kdeinit5[603]: Handler: 0
Feb 03 13:18:15 laptop kdeinit5[603]: Exclude: 0x0  Match?  false
Feb 03 13:18:15 laptop kdeinit5[603]: false
Feb 03 13:18:15 laptop kdeinit5[603]: Gesture ungrab
Comment 1 Marco Martin 2015-02-06 10:50:46 UTC
are the applications such as Dolphin or konqueror KDE4 or KF5 based?

any idea who is actually writing user-places.xbel ?
Comment 2 Jiehong 2015-02-06 11:22:16 UTC
Dolphin
Version 14.11.97 (actually 14.12.1 according to the package)
Using KDE Development Platform 4.14.4

Konqueror
Version 4.14.4 (actually 14.12.1 according to the package)
Using KDE Development Platform 4.14.4

I wish I knew what application were modifying the file, but I only have the information of when that file were modified (with stat for example).

Logs don't contain `user-places`, and the activity around the time of modification is not very helpful.

`audit` is not activated in the Archlinux kernel, so monitoring the file's access and modifications require a custom kernel that I haven't.
Comment 3 Emmanuel Pescosta 2015-02-08 13:11:04 UTC
Duplicate of bug 342685?
Comment 4 David Edmundson 2015-02-08 13:12:46 UTC
looks it, thanks.

*** This bug has been marked as a duplicate of bug 342685 ***
Comment 5 Marco Martin 2015-02-09 17:22:47 UTC
Git commit e7e0f2d8f06e4086a1872757d779e19a06537b2a by Marco Martin.
Committed on 09/02/2015 at 17:18.
Pushed by mart into branch 'master'.

sync bookmarkmanager only if change was by process

This is an attempt to fix a bug that seems quite difficult to reproduce,
It seems there is a weird race condition linked to the sync of the two files
.local/share/user-places.xbel
.local/share/kfileplaces/bookmarks.xml
causing the bug
https://bugs.kde.org/show_bug.cgi?id=343735
all processes that are listening for changes in the bookmark manager will
try to sync their bookmarks with the shared ones (user-places.xbel)
and depending what process arrives first, some bookmarks may be lost

The same commit will happen on kdelibs4 as well
REVIEW:122459

M  +9    -0    src/filewidgets/kfileplacesmodel.cpp
M  +1    -6    src/filewidgets/kfileplacessharedbookmarks.cpp
M  +2    -1    src/filewidgets/kfileplacessharedbookmarks_p.h

http://commits.kde.org/kio/e7e0f2d8f06e4086a1872757d779e19a06537b2a
Comment 6 Marco Martin 2015-02-09 17:23:20 UTC
Git commit 2b5c6e42fc8114c6854ce490b9cdd4356be683d9 by Marco Martin.
Committed on 09/02/2015 at 17:22.
Pushed by mart into branch 'KDE/4.14'.

sync bookmarkmanager only if change was by process

This is an attempt to fix a bug that seems quite difficult to reproduce,
It seems there is a weird race condition linked to the sync of the two files
.local/share/user-places.xbel
.local/share/kfileplaces/bookmarks.xml
causing the bug
https://bugs.kde.org/show_bug.cgi?id=343735
all processes that are listening for changes in the bookmark manager will
try to sync their bookmarks with the shared ones (user-places.xbel)
and depending what process arrives first, some bookmarks may be lost

The same commit will happen on kdelibs4 as well
REVIEW:122459

M  +9    -0    kfile/kfileplacesmodel.cpp
M  +1    -6    kfile/kfileplacessharedbookmarks.cpp
M  +2    -2    kfile/kfileplacessharedbookmarks_p.h

http://commits.kde.org/kdelibs/2b5c6e42fc8114c6854ce490b9cdd4356be683d9
Comment 7 Marco Martin 2015-02-09 17:25:19 UTC
Emmanuel: should the same commit happen on dolphin as well?
or even better: could Dolphin be made use kfileplacesmodel (expanded as necessary) as well?
Comment 8 Emmanuel Pescosta 2015-02-11 16:15:41 UTC
(In reply to Marco Martin from comment #7)
> Emmanuel: should the same commit happen on dolphin as well?

Given that the Dolphin places model uses a lot of kfileplacesmodel code, I think we have to apply the same changes in Dolphin as well. But I'll check it and come up with a patch.

> could Dolphin be made use kfileplacesmodel (expanded as necessary) as well?

kfileplacesmodel and Dolphin have different model interfaces (QModelIndex vs itemviews-ng), so it isn't a real drop-in replacement. But merging them in the long term is definitely something to keep in mind ;)
Comment 9 Marco Silva 2015-03-17 14:10:50 UTC
still happens as of today in archlinux current. Using KDE 4.
could it be related to usage of KDE Connect? (since it edits user-places to add a item for remote browsing the phone)
Comment 10 Emmanuel Pescosta 2015-03-24 14:03:42 UTC
(In reply to Marco Silva from comment #9)
> still happens as of today in archlinux current. Using KDE 4.
> could it be related to usage of KDE Connect? (since it edits user-places to
> add a item for remote browsing the phone)

Please have a look at https://bugs.kde.org/show_bug.cgi?id=345174