[Bug 47647] Tp-qt fails to remove temp avatar file

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Sep 24 15:05:50 CEST 2012


https://bugs.freedesktop.org/show_bug.cgi?id=47647

--- Comment #5 from George Kiagiadakis <kiagiadakis.george at gmail.com> ---
(In reply to comment #3)
> From qt docs:
> If a file with the name newName already exists, rename() returns false
> (i.e., QFile will not overwrite it).

Indeed, this is the bug. For some reason, avatars are retrieved multiple times,
even from the same application, and only the first time succeeds. Later on,
temporary files are written but not renamed to the proper avatar file name and
not removed either.

This patch addresses the problem, but it is not correct in the sense that it is
not atomic. There could be a race condition between two processes trying to
retrieve the same avatar at the same time.

This trick with QTemporaryFile is based on g_file_set_contents() that tp-glib
uses, which guarantees an atomic operation, but only on unix. On windows, it
behaves like this patch (it removes the original file first, then renames).
Now, we could implement a similar function in tp-qt, using the posix rename()
function, but it wouldn't work on windows for the same reason that it doesn't
work for g_file_set_contents() on windows.

Therefore, a better solution, imho, would be to just ignore the new avatar data
if the file already exists on the hard drive, since it is guaranteed that two
avatars with the same token and from the same CM/protocol have exactly the same
contents. I don't really see a reason why we should overwrite the existing data
with the same data. Opinions?

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/telepathy-bugs/attachments/20120924/8036867a/attachment.html>


More information about the telepathy-bugs mailing list