~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to camel/providers/local/camel-mbox-store.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
G_DEFINE_TYPE (CamelMboxStore, camel_mbox_store, CAMEL_TYPE_LOCAL_STORE)
42
42
 
43
43
static const gchar *extensions[] = {
44
 
        ".msf", ".ev-summary", ".ev-summary-meta", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock", ".db", ".journal"
 
44
        ".msf",
 
45
        ".ev-summary",
 
46
        ".ev-summary-meta",
 
47
        ".ibex.index",
 
48
        ".ibex.index.data",
 
49
        ".cmeta",
 
50
        ".lock",
 
51
        ".db",
 
52
        ".journal"
45
53
};
46
54
 
47
55
/* used to find out where we've visited already */
92
100
                        return TRUE;
93
101
        }
94
102
 
95
 
        if (sbd && flen > 4 && !strcmp(filename + flen - 4, ".sbd"))
 
103
        if (sbd && flen > 4 && !strcmp (filename + flen - 4, ".sbd"))
96
104
                return TRUE;
97
105
 
98
106
        return FALSE;
122
130
 
123
131
                local_store = CAMEL_LOCAL_STORE (store);
124
132
 
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);
128
137
 
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);
134
146
                }
135
147
 
136
148
                g_object_unref (mbs);
139
151
 
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);
 
154
                fi->flags =
 
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);
144
158
}
145
159
 
146
160
static CamelFolderInfo *
178
192
                if (ignore_file (dent, FALSE))
179
193
                        continue;
180
194
 
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) {
183
197
                        g_free (path);
184
198
                        continue;
194
208
                }
195
209
#endif
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"))
198
212
                        *ext = '\0';
199
213
 
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);
202
216
                else
203
217
                        full_name = g_strdup (short_name);
204
218
 
207
221
                        g_free (full_name);
208
222
 
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;
211
225
                        } else {
212
226
                                fi->flags &= ~CAMEL_FOLDER_NOSELECT;
213
227
                        }
250
264
                                if ((fi->child = scan_dir (store, visited, fi, path, fi->full_name, flags, error)))
251
265
                                        fi->flags |= CAMEL_FOLDER_CHILDREN;
252
266
                                else
253
 
                                        fi->flags =(fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN;
 
267
                                        fi->flags = (fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN;
254
268
                        }
255
269
                }
256
270
 
395
409
 
396
410
                g_free (dirname);
397
411
 
398
 
                fd = g_open (name, O_LARGEFILE | O_WRONLY | O_CREAT | O_APPEND | O_BINARY, 0666);
 
412
                fd = g_open (
 
413
                        name,
 
414
                        O_LARGEFILE |
 
415
                        O_WRONLY |
 
416
                        O_CREAT |
 
417
                        O_APPEND |
 
418
                        O_BINARY, 0666);
 
419
 
399
420
                if (fd == -1) {
400
421
                        g_set_error (
401
422
                                error, G_IO_ERROR,
476
497
 
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);
480
501
 
481
502
                if (g_stat (test_if_subdir, &st) == -1) {
482
503
                        g_free (path);
499
520
 
500
521
        fill_fi (store, fi, flags);
501
522
 
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,
527
548
                               GError **error)
528
549
{
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
 
553
         *       parent's code? */
531
554
        CamelLocalSettings *local_settings;
532
555
        CamelLocalStore *local_store;
533
556
        CamelFolderInfo *info = NULL;
541
564
        struct stat st;
542
565
 
543
566
        service = CAMEL_SERVICE (store);
544
 
        settings = camel_service_get_settings (service);
 
567
 
 
568
        settings = camel_service_ref_settings (service);
545
569
 
546
570
        local_settings = CAMEL_LOCAL_SETTINGS (settings);
547
571
        root_path = camel_local_settings_dup_path (local_settings);
548
572
 
 
573
        g_object_unref (settings);
 
574
 
549
575
        local_store = CAMEL_LOCAL_STORE (store);
550
576
 
551
577
        if (!g_path_is_absolute (root_path)) {
624
650
 
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);
628
654
 
629
655
        if (g_rmdir (path) == -1 && errno != ENOENT) {
630
656
                g_set_error (
822
848
                        goto ibex_failed;
823
849
                }
824
850
        } else {
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;
829
856
                }
830
857
        }
831
858
 
832
 
        if (xrename(store, old, new, ".ev-summary", TRUE) == -1) {
833
 
                errnosav = errno;
834
 
                goto summary_failed;
835
 
        }
836
 
 
837
 
        if (xrename(store, old, new, ".ev-summary-meta", TRUE) == -1) {
838
 
                errnosav = errno;
839
 
                goto summary_failed;
840
 
        }
841
 
 
842
 
        if (xrename(store, old, new, ".cmeta", TRUE) == -1) {
 
859
        if (xrename (store, old, new, ".ev-summary", TRUE) == -1) {
 
860
                errnosav = errno;
 
861
                goto summary_failed;
 
862
        }
 
863
 
 
864
        if (xrename (store, old, new, ".ev-summary-meta", TRUE) == -1) {
 
865
                errnosav = errno;
 
866
                goto summary_failed;
 
867
        }
 
868
 
 
869
        if (xrename (store, old, new, ".cmeta", TRUE) == -1) {
843
870
                errnosav = errno;
844
871
                goto cmeta_failed;
845
872
        }
846
873
 
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;
850
877
        }
863
890
        return TRUE;
864
891
 
865
892
base_failed:
866
 
        xrename(store, new, old, ".sbd", TRUE);
 
893
        xrename (store, new, old, ".sbd", TRUE);
867
894
subdir_failed:
868
 
        xrename(store, new, old, ".cmeta", TRUE);
 
895
        xrename (store, new, old, ".cmeta", TRUE);
869
896
cmeta_failed:
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);
872
899
summary_failed:
873
900
        if (folder) {
874
901
                if (folder->index)
904
931
        CamelLocalSettings *local_settings;
905
932
        CamelSettings *settings;
906
933
        CamelService *service;
907
 
        const gchar *inptr = full_name;
908
 
        gint subdirs = 0;
 
934
        GString *full_path;
909
935
        gchar *root_path;
910
 
        gchar *path, *p;
 
936
        const gchar *cp;
911
937
 
912
938
        service = CAMEL_SERVICE (ls);
913
 
        settings = camel_service_get_settings (service);
 
939
 
 
940
        settings = camel_service_ref_settings (service);
914
941
 
915
942
        local_settings = CAMEL_LOCAL_SETTINGS (settings);
916
943
        root_path = camel_local_settings_dup_path (local_settings);
 
944
 
 
945
        g_object_unref (settings);
 
946
 
917
947
        g_return_val_if_fail (root_path != NULL, NULL);
918
948
 
919
 
        while (*inptr != '\0') {
920
 
                if (G_IS_DIR_SEPARATOR (*inptr))
921
 
                        subdirs++;
922
 
                inptr++;
 
949
        full_path = g_string_new (root_path);
 
950
 
 
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);
 
954
 
 
955
        cp = full_name;
 
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++);
 
960
 
 
961
                        /* Skip extranaeous separators. */
 
962
                        while (G_IS_DIR_SEPARATOR (*cp))
 
963
                                cp++;
 
964
                } else {
 
965
                        g_string_append_c (full_path, *cp++);
 
966
                }
923
967
        }
924
968
 
925
 
        path = g_malloc (strlen (root_path) + (inptr - full_name) + (4 * subdirs) + 1);
926
 
        p = g_stpcpy (path, root_path);
927
 
 
928
969
        g_free (root_path);
929
970
 
930
 
        inptr = full_name;
931
 
        while (*inptr != '\0') {
932
 
                while (!G_IS_DIR_SEPARATOR (*inptr) && *inptr != '\0')
933
 
                        *p++ = *inptr++;
934
 
 
935
 
                if (G_IS_DIR_SEPARATOR (*inptr)) {
936
 
                        p = g_stpcpy (p, ".sbd/");
937
 
                        inptr++;
938
 
 
939
 
                        /* strip extranaeous '/'s */
940
 
                        while (G_IS_DIR_SEPARATOR (*inptr))
941
 
                                inptr++;
942
 
                }
943
 
        }
944
 
 
945
 
        *p = '\0';
946
 
 
947
 
        return path;
 
971
        return g_string_free (full_path, FALSE);
948
972
}
949
973
 
950
974
static gchar *
958
982
 
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);
 
985
                sprintf (
 
986
                        name, "%.*s.%s%s",
 
987
                        slash - full_name + 1,
 
988
                        full_name, slash + 1, ext);
962
989
        else
963
990
                sprintf (name, ".%s%s", full_name, ext);
964
991