"snoozing" with notmuch?
[notmuch-archives.git] / 9c / e106ae410500577dc6a3fb069ef38dbeb4ff83
1 Return-Path: <too@guru-group.fi>\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 021F9431FD6\r
6         for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 11:18:59 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 pPXkDCG6riJQ for <notmuch@notmuchmail.org>;\r
16         Sun, 23 Feb 2014 11:18:55 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 65CDB431FCF\r
19         for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 11:18:55 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id A6987100086; Sun, 23 Feb 2014 21:18:49 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel\r
25         directories\r
26 Date: Sun, 23 Feb 2014 21:18:47 +0200\r
27 Message-Id: <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi>\r
28 X-Mailer: git-send-email 1.8.0\r
29 In-Reply-To: <87mwhifu9a.fsf@trouble.defaultvalue.org>\r
30 References: <87mwhifu9a.fsf@trouble.defaultvalue.org>\r
31 Cc: tomi.ollila@iki.fi\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Sun, 23 Feb 2014 19:18:59 -0000\r
45 \r
46 So that users may have email in subdir/.notmuch directories.\r
47 ---\r
48 \r
49 Compiles, current tests pass. might ignore database_path/.notmuch and\r
50 might descent into database_path/.../.notmuch :D\r
51 \r
52 Tomi\r
53 \r
54 \r
55  notmuch-new.c | 18 ++++++++++--------\r
56  1 file changed, 10 insertions(+), 8 deletions(-)\r
57 \r
58 diff --git a/notmuch-new.c b/notmuch-new.c\r
59 index 8529fdd..b17bd75 100644\r
60 --- a/notmuch-new.c\r
61 +++ b/notmuch-new.c\r
62 @@ -344,7 +344,8 @@ add_file (notmuch_database_t *notmuch, const char *filename,\r
63  static notmuch_status_t\r
64  add_files (notmuch_database_t *notmuch,\r
65            const char *path,\r
66 -          add_files_state_t *state)\r
67 +          add_files_state_t *state,\r
68 +          int dirlevel)\r
69  {\r
70      DIR *dir = NULL;\r
71      struct dirent *entry = NULL;\r
72 @@ -469,11 +470,11 @@ add_files (notmuch_database_t *notmuch,\r
73         if (strcmp (entry->d_name, ".") == 0 ||\r
74             strcmp (entry->d_name, "..") == 0 ||\r
75             (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||\r
76 -           strcmp (entry->d_name, ".notmuch") == 0)\r
77 +           (dirlevel == 0 && strcmp (entry->d_name, ".notmuch") == 0))\r
78             continue;\r
79  \r
80         next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
81 -       status = add_files (notmuch, next, state);\r
82 +       status = add_files (notmuch, next, state, dirlevel + 1);\r
83         if (status) {\r
84             ret = status;\r
85             goto DONE;\r
86 @@ -702,7 +703,8 @@ stop_progress_printing_timer (void)\r
87   * initialized to zero by the top-level caller before calling\r
88   * count_files). */\r
89  static void\r
90 -count_files (const char *path, int *count, add_files_state_t *state)\r
91 +count_files (const char *path, int *count, add_files_state_t *state,\r
92 +            int dirlevel)\r
93  {\r
94      struct dirent *entry = NULL;\r
95      char *next;\r
96 @@ -725,7 +727,7 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
97          */\r
98         if (strcmp (entry->d_name, ".") == 0 ||\r
99             strcmp (entry->d_name, "..") == 0 ||\r
100 -           strcmp (entry->d_name, ".notmuch") == 0 ||\r
101 +           (dirlevel == 0 && strcmp (entry->d_name, ".notmuch") == 0) ||\r
102             _entry_in_ignore_list (entry->d_name, state))\r
103         {\r
104             if (state->debug && _entry_in_ignore_list (entry->d_name, state))\r
105 @@ -750,7 +752,7 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
106                 fflush (stdout);\r
107             }\r
108         } else if (entry_type == S_IFDIR) {\r
109 -           count_files (next, count, state);\r
110 +           count_files (next, count, state, dirlevel + 1);\r
111         }\r
112  \r
113         free (next);\r
114 @@ -962,7 +964,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
115         int count;\r
116  \r
117         count = 0;\r
118 -       count_files (db_path, &count, &add_files_state);\r
119 +       count_files (db_path, &count, &add_files_state, 0);\r
120         if (interrupted)\r
121             return EXIT_FAILURE;\r
122  \r
123 @@ -1021,7 +1023,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
124         timer_is_active = TRUE;\r
125      }\r
126  \r
127 -    ret = add_files (notmuch, db_path, &add_files_state);\r
128 +    ret = add_files (notmuch, db_path, &add_files_state, 0);\r
129      if (ret)\r
130         goto DONE;\r
131  \r
132 -- \r
133 1.8.4.2\r
134 \r