41
41
G_DEFINE_TYPE (CamelMboxStore, camel_mbox_store, CAMEL_TYPE_LOCAL_STORE)
43
43
static const gchar *extensions[] = {
44
".msf", ".ev-summary", ".ev-summary-meta", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock", ".db", ".journal"
47
55
/* used to find out where we've visited already */
123
131
local_store = CAMEL_LOCAL_STORE (store);
125
/* This should be fast enough not to have to test for INFO_FAST */
133
/* This should be fast enough not
134
* to have to test for INFO_FAST. */
126
135
folderpath = camel_local_store_get_full_path (
127
136
local_store, fi->full_name);
129
mbs = (CamelMboxSummary *) camel_mbox_summary_new (NULL, folderpath, NULL);
138
mbs = (CamelMboxSummary *) camel_mbox_summary_new (
139
NULL, folderpath, NULL);
130
140
/* FIXME[disk-summary] track exception */
131
141
if (camel_folder_summary_header_load_from_db ((CamelFolderSummary *) mbs, store, fi->full_name, NULL)) {
132
fi->unread = camel_folder_summary_get_unread_count ((CamelFolderSummary *) mbs);
133
fi->total = camel_folder_summary_get_saved_count ((CamelFolderSummary *) mbs);
142
fi->unread = camel_folder_summary_get_unread_count (
143
(CamelFolderSummary *) mbs);
144
fi->total = camel_folder_summary_get_saved_count (
145
(CamelFolderSummary *) mbs);
136
148
g_object_unref (mbs);
140
152
if (camel_local_store_is_main_store (CAMEL_LOCAL_STORE (store)) && fi->full_name
141
153
&& (fi->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_NORMAL)
142
fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK)
143
| camel_local_store_get_folder_type_by_full_name (CAMEL_LOCAL_STORE (store), fi->full_name);
155
(fi->flags & ~CAMEL_FOLDER_TYPE_MASK) |
156
camel_local_store_get_folder_type_by_full_name (
157
CAMEL_LOCAL_STORE (store), fi->full_name);
146
160
static CamelFolderInfo *
178
192
if (ignore_file (dent, FALSE))
181
path = g_strdup_printf("%s/%s", root, dent);
195
path = g_strdup_printf ("%s/%s", root, dent);
182
196
if (g_stat (path, &st) == -1) {
196
210
short_name = g_strdup (dent);
197
if ((ext = strrchr(short_name, '.')) && !strcmp(ext, ".sbd"))
211
if ((ext = strrchr (short_name, '.')) && !strcmp (ext, ".sbd"))
200
214
if (name != NULL)
201
full_name = g_strdup_printf("%s/%s", name, short_name);
215
full_name = g_strdup_printf ("%s/%s", name, short_name);
203
217
full_name = g_strdup (short_name);
207
221
g_free (full_name);
209
223
if (S_ISDIR (st.st_mode)) {
210
fi->flags =(fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN;
224
fi->flags = (fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN;
212
226
fi->flags &= ~CAMEL_FOLDER_NOSELECT;
250
264
if ((fi->child = scan_dir (store, visited, fi, path, fi->full_name, flags, error)))
251
265
fi->flags |= CAMEL_FOLDER_CHILDREN;
253
fi->flags =(fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN;
267
fi->flags = (fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN;
477
498
/* requesting scan of specific folder */
478
499
if (g_stat (path, &st) == -1 || !S_ISREG (st.st_mode)) {
479
char *test_if_subdir = g_strdup_printf("%s.sbd", path);
500
gchar *test_if_subdir = g_strdup_printf ("%s.sbd", path);
481
502
if (g_stat (test_if_subdir, &st) == -1) {
500
521
fill_fi (store, fi, flags);
502
subdir = g_strdup_printf("%s.sbd", path);
523
subdir = g_strdup_printf ("%s.sbd", path);
503
524
if (g_stat (subdir, &st) == 0) {
504
525
if (S_ISDIR (st.st_mode))
505
526
fi->child = scan_dir (store, visited, fi, subdir, top, flags, error);
526
547
GCancellable *cancellable,
529
/* FIXME: this is almost an exact copy of CamelLocalStore::create_folder() except that we use
530
* different path schemes... need to find a way to share parent's code? */
550
/* FIXME This is almost an exact copy of
551
* CamelLocalStore::create_folder() except that we use
552
* different path schemes - need to find a way to share
531
554
CamelLocalSettings *local_settings;
532
555
CamelLocalStore *local_store;
533
556
CamelFolderInfo *info = NULL;
543
566
service = CAMEL_SERVICE (store);
544
settings = camel_service_get_settings (service);
568
settings = camel_service_ref_settings (service);
546
570
local_settings = CAMEL_LOCAL_SETTINGS (settings);
547
571
root_path = camel_local_settings_dup_path (local_settings);
573
g_object_unref (settings);
549
575
local_store = CAMEL_LOCAL_STORE (store);
551
577
if (!g_path_is_absolute (root_path)) {
625
651
local_store = CAMEL_LOCAL_STORE (store);
626
652
name = camel_local_store_get_full_path (local_store, folder_name);
627
path = g_strdup_printf("%s.sbd", name);
653
path = g_strdup_printf ("%s.sbd", name);
629
655
if (g_rmdir (path) == -1 && errno != ENOENT) {
822
848
goto ibex_failed;
825
/* TODO: camel_text_index_rename should find out if we have an active index itself? */
851
/* TODO camel_text_index_rename should find out
852
* if we have an active index itself? */
826
853
if (camel_text_index_rename (oldibex, newibex) == -1 && errno != ENOENT) {
827
854
errnosav = errno;
828
855
goto ibex_failed;
832
if (xrename(store, old, new, ".ev-summary", TRUE) == -1) {
837
if (xrename(store, old, new, ".ev-summary-meta", TRUE) == -1) {
842
if (xrename(store, old, new, ".cmeta", TRUE) == -1) {
859
if (xrename (store, old, new, ".ev-summary", TRUE) == -1) {
864
if (xrename (store, old, new, ".ev-summary-meta", TRUE) == -1) {
869
if (xrename (store, old, new, ".cmeta", TRUE) == -1) {
843
870
errnosav = errno;
844
871
goto cmeta_failed;
847
if (xrename(store, old, new, ".sbd", TRUE) == -1) {
874
if (xrename (store, old, new, ".sbd", TRUE) == -1) {
848
875
errnosav = errno;
849
876
goto subdir_failed;
866
xrename(store, new, old, ".sbd", TRUE);
893
xrename (store, new, old, ".sbd", TRUE);
868
xrename(store, new, old, ".cmeta", TRUE);
895
xrename (store, new, old, ".cmeta", TRUE);
870
xrename(store, new, old, ".ev-summary", TRUE);
871
xrename(store, new, old, ".ev-summary-meta", TRUE);
897
xrename (store, new, old, ".ev-summary", TRUE);
898
xrename (store, new, old, ".ev-summary-meta", TRUE);
874
901
if (folder->index)
904
931
CamelLocalSettings *local_settings;
905
932
CamelSettings *settings;
906
933
CamelService *service;
907
const gchar *inptr = full_name;
909
935
gchar *root_path;
912
938
service = CAMEL_SERVICE (ls);
913
settings = camel_service_get_settings (service);
940
settings = camel_service_ref_settings (service);
915
942
local_settings = CAMEL_LOCAL_SETTINGS (settings);
916
943
root_path = camel_local_settings_dup_path (local_settings);
945
g_object_unref (settings);
917
947
g_return_val_if_fail (root_path != NULL, NULL);
919
while (*inptr != '\0') {
920
if (G_IS_DIR_SEPARATOR (*inptr))
949
full_path = g_string_new (root_path);
951
/* Root path may or may not have a trailing separator. */
952
if (!g_str_has_suffix (root_path, G_DIR_SEPARATOR_S))
953
g_string_append_c (full_path, G_DIR_SEPARATOR);
956
while (*cp != '\0') {
957
if (G_IS_DIR_SEPARATOR (*cp)) {
958
g_string_append (full_path, ".sbd");
959
g_string_append_c (full_path, *cp++);
961
/* Skip extranaeous separators. */
962
while (G_IS_DIR_SEPARATOR (*cp))
965
g_string_append_c (full_path, *cp++);
925
path = g_malloc (strlen (root_path) + (inptr - full_name) + (4 * subdirs) + 1);
926
p = g_stpcpy (path, root_path);
928
969
g_free (root_path);
931
while (*inptr != '\0') {
932
while (!G_IS_DIR_SEPARATOR (*inptr) && *inptr != '\0')
935
if (G_IS_DIR_SEPARATOR (*inptr)) {
936
p = g_stpcpy (p, ".sbd/");
939
/* strip extranaeous '/'s */
940
while (G_IS_DIR_SEPARATOR (*inptr))
971
return g_string_free (full_path, FALSE);
959
983
name = g_alloca (strlen (full_name) + strlen (ext) + 2);
960
984
if ((slash = strrchr (full_name, '/')))
961
sprintf (name, "%.*s.%s%s", slash - full_name + 1, full_name, slash + 1, ext);
987
slash - full_name + 1,
988
full_name, slash + 1, ext);
963
990
sprintf (name, ".%s%s", full_name, ext);