aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-setup.c
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-11-11 19:50:15 -0800
committerGravatar Carl Worth <cworth@cworth.org>2009-11-11 19:50:15 -0800
commit37bdd8987094220c84ec39f8f550753219f68bd4 (patch)
tree6c6c068c4a6357c29da7a040e4c0cbe8b173233f /notmuch-setup.c
parent8136e15229adc99197e4b4617e849180a66d6049 (diff)
notmuch new: Unbreak after the addition of notmuch-config.
Pull in the code from add-files.c now that notmuch_new_command is the only user, (we no longer have notmuch_setup_command adding any messages).
Diffstat (limited to 'notmuch-setup.c')
-rw-r--r--notmuch-setup.c125
1 files changed, 0 insertions, 125 deletions
diff --git a/notmuch-setup.c b/notmuch-setup.c
index 2c3404ff..482efd2e 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -20,131 +20,6 @@
#include "notmuch-client.h"
-static notmuch_status_t
-add_all_files (notmuch_database_t *notmuch,
- const char *mail_directory,
- int num_files)
-{
- add_files_state_t add_files_state;
- double elapsed;
- struct timeval tv_now;
- notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
-
- add_files_state.ignore_read_only_directories = FALSE;
- add_files_state.saw_read_only_directory = FALSE;
- add_files_state.total_files = num_files;
- add_files_state.processed_files = 0;
- add_files_state.added_messages = 0;
- add_files_state.callback = NULL;
- gettimeofday (&add_files_state.tv_start, NULL);
-
- ret = add_files (notmuch, mail_directory, &add_files_state);
-
- gettimeofday (&tv_now, NULL);
- elapsed = notmuch_time_elapsed (add_files_state.tv_start,
- tv_now);
- printf ("Processed %d %s in ", add_files_state.processed_files,
- add_files_state.processed_files == 1 ?
- "file" : "total files");
- notmuch_time_print_formatted_seconds (elapsed);
- if (elapsed > 1) {
- printf (" (%d files/sec.). \n",
- (int) (add_files_state.processed_files / elapsed));
- } else {
- printf (". \n");
- }
- if (add_files_state.added_messages) {
- printf ("Added %d %s to the database.\n\n",
- add_files_state.added_messages,
- add_files_state.added_messages == 1 ?
- "message" : "unique messages");
- }
-
- return ret;
-}
-
-
-/* XXX: This should be merged with the existing add_files function in
- * add-files.c. */
-/* Recursively count all regular files in path and all sub-direcotries
- * of path. The result is added to *count (which should be
- * initialized to zero by the top-level caller before calling
- * count_files). */
-static void
-count_files (const char *path, int *count)
-{
- DIR *dir;
- struct dirent *e, *entry = NULL;
- int entry_length;
- int err;
- char *next;
- struct stat st;
-
- dir = opendir (path);
-
- if (dir == NULL) {
- fprintf (stderr, "Warning: failed to open directory %s: %s\n",
- path, strerror (errno));
- goto DONE;
- }
-
- entry_length = offsetof (struct dirent, d_name) +
- pathconf (path, _PC_NAME_MAX) + 1;
- entry = malloc (entry_length);
-
- while (1) {
- err = readdir_r (dir, entry, &e);
- if (err) {
- fprintf (stderr, "Error reading directory: %s\n",
- strerror (errno));
- free (entry);
- goto DONE;
- }
-
- if (e == NULL)
- break;
-
- /* Ignore special directories to avoid infinite recursion.
- * Also ignore the .notmuch directory.
- */
- /* XXX: Eventually we'll want more sophistication to let the
- * user specify files to be ignored. */
- if (strcmp (entry->d_name, ".") == 0 ||
- strcmp (entry->d_name, "..") == 0 ||
- strcmp (entry->d_name, ".notmuch") == 0)
- {
- continue;
- }
-
- if (asprintf (&next, "%s/%s", path, entry->d_name) == -1) {
- next = NULL;
- fprintf (stderr, "Error descending from %s to %s: Out of memory\n",
- path, entry->d_name);
- continue;
- }
-
- stat (next, &st);
-
- if (S_ISREG (st.st_mode)) {
- *count = *count + 1;
- if (*count % 1000 == 0) {
- printf ("Found %d files so far.\r", *count);
- fflush (stdout);
- }
- } else if (S_ISDIR (st.st_mode)) {
- count_files (next, count);
- }
-
- free (next);
- }
-
- DONE:
- if (entry)
- free (entry);
-
- closedir (dir);
-}
-
static const char *
make_path_absolute (void *ctx, const char *path)
{