if (num_fs_entries == -1) {
fprintf (stderr, "Error opening directory %s: %s\n",
path, strerror (errno));
+ /* We consider this a fatal error because, if a user moved a
+ * message from another directory that we were able to scan
+ * into this directory, skipping this directory will cause
+ * that message to be lost. */
ret = NOTMUCH_STATUS_FILE_ERROR;
goto DONE;
}
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
status = add_files_recursive (notmuch, next, state);
- if (status && ret == NOTMUCH_STATUS_SUCCESS)
+ if (status) {
ret = status;
+ goto DONE;
+ }
talloc_free (next);
next = NULL;
}
}
ret = add_files (notmuch, db_path, &add_files_state);
+ if (ret)
+ goto DONE;
gettimeofday (&tv_start, NULL);
for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {
}
}
+ DONE:
talloc_free (add_files_state.removed_files);
talloc_free (add_files_state.removed_directories);
talloc_free (add_files_state.directory_mtimes);
printf ("\n");
- if (ret) {
- printf ("\nNote: At least one error was encountered: %s\n",
+ if (ret)
+ printf ("\nNote: A fatal error was encountered: %s\n",
notmuch_status_to_string (ret));
- }
notmuch_database_close (notmuch);