Gentoo Archives: gentoo-commits

From: "Johannes Huber (johu)" <johu@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-libs/telepathy-qt/files: telepathy-qt-0.9.3-avatar-duplication.patch
Date: Wed, 05 Jun 2013 21:35:45
Message-Id: 20130605213540.1C9CF2171D@flycatcher.gentoo.org
1 johu 13/06/05 21:35:40
2
3 Added: telepathy-qt-0.9.3-avatar-duplication.patch
4 Log:
5 Revision bump. EAPI 5, migrate to non obsolete python eclass, adds upstream patch which fixes avatars stored several times when they exist spotted by Lamarque V. Souza <lamarque@×××××.com> wrt bug #472180.
6
7 (Portage version: 2.2.0_alpha177/cvs/Linux x86_64, signed Manifest commit with key F3CFD2BD)
8
9 Revision Changes Path
10 1.1 net-libs/telepathy-qt/files/telepathy-qt-0.9.3-avatar-duplication.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-libs/telepathy-qt/files/telepathy-qt-0.9.3-avatar-duplication.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-libs/telepathy-qt/files/telepathy-qt-0.9.3-avatar-duplication.patch?rev=1.1&content-type=text/plain
14
15 Index: telepathy-qt-0.9.3-avatar-duplication.patch
16 ===================================================================
17 From 8da9f7069929893bcee64dab22101134752fe618 Mon Sep 17 00:00:00 2001
18 From: George Kiagiadakis <george.kiagiadakis@×××××××××.com>
19 Date: Thu, 07 Feb 2013 12:37:49 +0000
20 Subject: Fix storing avatars, so that they are not stored millions of times each
21
22 The original problem lies in the fact that QFile::rename() does not overwrite
23 existing files. Therefore it fails and the temporary file stays on the
24 filesystem together with the already existing avatar file. Checking if the file
25 exists before renaming solves this partially, but the problem is that this
26 operation is not atomic. There can be many processes using tp-qt, fetching
27 avatars at the same time from the server, and in this case we can still have
28 a problem there. The final solution is to ignore a new avatar that has the same
29 token as an avatar that is already on the filesystem. According to the spec,
30 different avatars have different tokens, so if an avatar changes, the token
31 changes as well.
32
33 https://bugs.freedesktop.org/show_bug.cgi?id=47647
34
35 Reviewed-by: David Edmundson <kde@×××××××××××××××××.uk>
36 ---
37 diff --git a/TelepathyQt/contact-manager.cpp b/TelepathyQt/contact-manager.cpp
38 index a67e736..dfa28bc 100644
39 --- a/TelepathyQt/contact-manager.cpp
40 +++ b/TelepathyQt/contact-manager.cpp
41 @@ -1341,17 +1341,27 @@ void ContactManager::onAvatarRetrieved(uint handle, const QString &token,
42 debug() << "Filename:" << avatarFileName;
43 debug() << "MimeType:" << mimeType;
44
45 - QTemporaryFile mimeTypeFile(mimeTypeFileName);
46 - mimeTypeFile.open();
47 - mimeTypeFile.write(mimeType.toLatin1());
48 - mimeTypeFile.setAutoRemove(false);
49 - mimeTypeFile.rename(mimeTypeFileName);
50 -
51 - QTemporaryFile avatarFile(avatarFileName);
52 - avatarFile.open();
53 - avatarFile.write(data);
54 - avatarFile.setAutoRemove(false);
55 - avatarFile.rename(avatarFileName);
56 + if (!QFile::exists(mimeTypeFileName)) {
57 + QTemporaryFile mimeTypeFile(mimeTypeFileName);
58 + if (mimeTypeFile.open()) {
59 + mimeTypeFile.write(mimeType.toLatin1());
60 + mimeTypeFile.setAutoRemove(false);
61 + if (!mimeTypeFile.rename(mimeTypeFileName)) {
62 + mimeTypeFile.remove();
63 + }
64 + }
65 + }
66 +
67 + if (!QFile::exists(avatarFileName)) {
68 + QTemporaryFile avatarFile(avatarFileName);
69 + if (avatarFile.open()) {
70 + avatarFile.write(data);
71 + avatarFile.setAutoRemove(false);
72 + if (!avatarFile.rename(avatarFileName)) {
73 + avatarFile.remove();
74 + }
75 + }
76 + }
77 }
78
79 ContactPtr contact = lookupContactByHandle(handle);
80 --
81 cgit v0.9.0.2-2-gbebe