Bug 33457

Summary: tp-qt4 uses non-atomic file write in avatar cache
Product: Telepathy Reporter: Xavier Claessens <xclaesse>
Component: tp-qtAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: ollisal
Version: unspecified   
Hardware: Other   
OS: All   
URL: http://git.collabora.co.uk/?p=user/xclaesse/telepathy-qt4.git;a=shortlog;h=refs/heads/atomic-write
Whiteboard:
i915 platform: i915 features:

Description Xavier Claessens 2011-01-25 03:59:23 UTC
The avatar cache is using not-atomic operation to store the image on-disk. This means when an avatar is updated, if more than on process is tracking its avatar data, they will both write the data into the cache at the same time. This is racy.

For now we could just create a QTemporaryFile then rename it. It's probably not 100% portable, but long-term solution is doing the cache in CM as said in bug #33410
Comment 1 Olli Salli 2011-01-25 04:04:23 UTC
Otherwise simple enough, but QFile::rename doesn't overwrite existing files. Looking at how similar tasks are implemented in KDE libraries could be a reasonable step forward.
Comment 2 Xavier Claessens 2011-01-25 04:50:40 UTC
Patch: http://git.collabora.co.uk/?p=user/xclaesse/telepathy-qt4.git;a=shortlog;h=refs/heads/atomic-write

I have to disable autoremove otherwise it remove the renamed file too :(
Comment 3 Xavier Claessens 2011-01-25 06:09:56 UTC
Branch merged.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.