Re: [PATCH 2/2] emacs: Prefer Content-Description over filename for part buttons
[notmuch-archives.git] / 90 / 671e248da76012fb30265b64f19c66ae6c4f25
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 84C65431FBD\r
6         for <notmuch@notmuchmail.org>; Sat,  2 Mar 2013 13:24:07 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id TOT+pJQO-nEX for <notmuch@notmuchmail.org>;\r
16         Sat,  2 Mar 2013 13:24:06 -0800 (PST)\r
17 Received: from mail-la0-f45.google.com (mail-la0-f45.google.com\r
18         [209.85.215.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B0915431FAF\r
21         for <notmuch@notmuchmail.org>; Sat,  2 Mar 2013 13:24:05 -0800 (PST)\r
22 Received: by mail-la0-f45.google.com with SMTP id er20so3975056lab.18\r
23         for <notmuch@notmuchmail.org>; Sat, 02 Mar 2013 13:24:04 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=x-received:from:to:cc:subject:date:message-id:x-mailer\r
27         :x-gm-message-state;\r
28         bh=zo9nARvV//OgxC31amhfUTTwZFB+68pdqmZgcSJGvKc=;\r
29         b=Wnk4ZSTRuN6PW592zQYX9kJGwFC9f/cGNPx2S8xL8Q5qFIKCA6pXzz2vYGJOuh0ZDm\r
30         9iC/3Se7pBZJMSaTE/sRARYfw9z2ToPO55ldVQ9fmpqhgFf6s43aguAUnb6EW3tUvDQD\r
31         KDvxfB9q+9hxR+rOxOpZmjDZirCj3VX1LDJUlhAsAnBd7kfSGzCzz/GRE+dnsrbYOagb\r
32         RESlqKWOj/nMnOMcLceK2wW6nguE0bh71SXIGOsOR8wAAPcfNXvmuYiOvS5e6hXsBIpM\r
33         14CHrcTHStE/Dmj71nd8FQvX53Zz0XVTCuJEm5tc18MGUqLmAAT1bBfMqa+wYkxujDQR\r
34         ca0w==\r
35 X-Received: by 10.152.46.17 with SMTP id r17mr13212033lam.47.1362259444006;\r
36         Sat, 02 Mar 2013 13:24:04 -0800 (PST)\r
37 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
38         [80.223.81.27])\r
39         by mx.google.com with ESMTPS id fm8sm5573848lbb.17.2013.03.02.13.24.02\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 02 Mar 2013 13:24:03 -0800 (PST)\r
42 From: Jani Nikula <jani@nikula.org>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH] config: do not overwrite symlinks when saving config file\r
45 Date: Sat,  2 Mar 2013 23:24:02 +0200\r
46 Message-Id: <1362259442-21014-1-git-send-email-jani@nikula.org>\r
47 X-Mailer: git-send-email 1.7.10.4\r
48 X-Gm-Message-State:\r
49  ALoCoQn1xtFMYHep2UHyAaHTFIyBAh+oSU7ICxxba7OH+PP8Vk9Kjc6YIQvg+aYccgI88xwYTvOq\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Sat, 02 Mar 2013 21:24:07 -0000\r
63 \r
64 Use realpath on the config path before writing. If that fails,\r
65 fallback to the previous behaviour.\r
66 \r
67 Previously 'notmuch setup' and 'notmuch config set' overwrote the\r
68 config file even if it was a symbolic link.\r
69 ---\r
70  notmuch-config.c |   10 ++++++++--\r
71  1 file changed, 8 insertions(+), 2 deletions(-)\r
72 \r
73 diff --git a/notmuch-config.c b/notmuch-config.c\r
74 index b5c2066..1e7389f 100644\r
75 --- a/notmuch-config.c\r
76 +++ b/notmuch-config.c\r
77 @@ -461,7 +461,7 @@ int\r
78  notmuch_config_save (notmuch_config_t *config)\r
79  {\r
80      size_t length;\r
81 -    char *data;\r
82 +    char *data, *filename;\r
83      GError *error = NULL;\r
84  \r
85      data = g_key_file_to_data (config->key_file, &length, NULL);\r
86 @@ -470,14 +470,20 @@ notmuch_config_save (notmuch_config_t *config)\r
87         return 1;\r
88      }\r
89  \r
90 -    if (! g_file_set_contents (config->filename, data, length, &error)) {\r
91 +    /* Try not to overwrite symlinks. */\r
92 +    filename = realpath (config->filename, NULL);\r
93 +\r
94 +    if (! g_file_set_contents (filename ? filename : config->filename,\r
95 +                              data, length, &error)) {\r
96         fprintf (stderr, "Error saving configuration to %s: %s\n",\r
97                  config->filename, error->message);\r
98         g_error_free (error);\r
99 +       free (filename);\r
100         g_free (data);\r
101         return 1;\r
102      }\r
103  \r
104 +    free (filename);\r
105      g_free (data);\r
106      return 0;\r
107  }\r
108 -- \r
109 1.7.10.4\r
110 \r