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

« back to all changes in this revision

Viewing changes to debian/patches/199-git-skip-empty-cache-files-ee21a86.patch

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-07 14:11:56 UTC
  • mfrom: (1.1.84 upstream)
  • Revision ID: james.westby@ubuntu.com-20110207141156-jakojbbkzee62447
Tags: 2.32.2-0ubuntu1
* New upstream release
* debian/patches/01_various_linking_issues.patch:
* debian/patches/02_fix_sources_migration.patch:
* debian/patches/199-git-backport-2.32.1-b08a6a1_to_2d0f4a3.patch:
* debian/patches/199-git-backport-2.32.1-to-b08a6a1.patch:
* debian/patches/199-git-skip-empty-cache-files-ee21a86.patch:
  - Fixed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From ee21a86b6ea8b84962d878924b2daeb5e3d2087b Mon Sep 17 00:00:00 2001
2
 
From: Matthew Barnes <mbarnes@redhat.com>
3
 
Date: Wed, 19 Jan 2011 02:27:37 +0000
4
 
Subject: Treat empty cache files as nonexistent.
5
 
 
6
 
For some reason, cached mail message files are sometimes winding up as
7
 
zero-length files.  Still need to figure out how this is happening, but
8
 
in the meantime teach Camel to disregard zero-length cache files.
9
 
---
10
 
diff --git a/camel/camel-data-cache.c b/camel/camel-data-cache.c
11
 
index f33b9b0..a72604c 100644
12
 
--- a/camel/camel-data-cache.c
13
 
+++ b/camel/camel-data-cache.c
14
 
@@ -420,8 +420,13 @@ camel_data_cache_get (CamelDataCache *cdc,
15
 
        real = data_cache_path(cdc, FALSE, path, key);
16
 
        stream = camel_object_bag_reserve(cdc->priv->busy_bag, real);
17
 
        if (!stream) {
18
 
-               stream = camel_stream_fs_new_with_name (
19
 
-                       real, O_RDWR, 0600, error);
20
 
+               struct stat st;
21
 
+
22
 
+               /* Return NULL if the file is empty. */
23
 
+               if (g_stat (real, &st) == 0 && st.st_size > 0)
24
 
+                       stream = camel_stream_fs_new_with_name (
25
 
+                               real, O_RDWR, 0600, error);
26
 
+
27
 
                if (stream)
28
 
                        camel_object_bag_add(cdc->priv->busy_bag, real, stream);
29
 
                else
30
 
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
31
 
index bde4026..179252d 100644
32
 
--- a/camel/providers/imapx/camel-imapx-server.c
33
 
+++ b/camel/providers/imapx/camel-imapx-server.c
34
 
@@ -5014,19 +5014,11 @@ imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperat
35
 
        CamelStream *stream = NULL, *tmp_stream;
36
 
        CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
37
 
        CamelIMAPXJob *job;
38
 
-       gchar *cache_file = NULL;
39
 
        CamelMessageInfo *mi;
40
 
        gboolean registered;
41
 
        EFlag *flag = NULL;
42
 
        gboolean success;
43
 
 
44
 
-       cache_file = camel_data_cache_get_filename  (ifolder->cache, "cur", uid, NULL);
45
 
-       if (g_file_test (cache_file, G_FILE_TEST_EXISTS)) {
46
 
-               g_free (cache_file);
47
 
-               return NULL;
48
 
-       }
49
 
-       g_free (cache_file);
50
 
-
51
 
        QUEUE_LOCK (is);
52
 
 
53
 
        if ((job = imapx_is_job_in_queue (is, folder, IMAPX_JOB_GET_MESSAGE, uid))) {
54
 
@@ -5039,11 +5031,11 @@ imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperat
55
 
 
56
 
                e_flag_wait (flag);
57
 
 
58
 
-               stream = camel_data_cache_get (ifolder->cache, "cur", uid, NULL);
59
 
-               if (!stream)
60
 
-                       g_set_error (
61
 
-                               error, CAMEL_IMAPX_ERROR, 1,
62
 
-                               "Could not retrieve the message");
63
 
+               stream = camel_data_cache_get (
64
 
+                       ifolder->cache, "cur", uid, error);
65
 
+               if (stream == NULL)
66
 
+                       g_prefix_error (
67
 
+                               error, "Could not retrieve the message: ");
68
 
                return stream;
69
 
        }
70
 
 
71
 
@@ -5116,12 +5108,17 @@ camel_imapx_server_sync_message (CamelIMAPXServer *is, CamelFolder *folder, cons
72
 
        gchar *cache_file = NULL;
73
 
        CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
74
 
        CamelStream *stream;
75
 
+       gboolean is_cached;
76
 
+       struct stat st;
77
 
+
78
 
+       /* Check if the cache file already exists and is non-empty. */
79
 
+       cache_file = camel_data_cache_get_filename (
80
 
+               ifolder->cache, "cur", uid, NULL);
81
 
+       is_cached = (g_stat (cache_file, &st) == 0 && st.st_size > 0);
82
 
+       g_free (cache_file);
83
 
 
84
 
-       cache_file = camel_data_cache_get_filename  (ifolder->cache, "cur", uid, NULL);
85
 
-       if (g_file_test (cache_file, G_FILE_TEST_EXISTS)) {
86
 
-               g_free (cache_file);
87
 
+       if (is_cached)
88
 
                return TRUE;
89
 
-       }
90
 
 
91
 
        stream = imapx_server_get_message (is, folder, NULL, uid, IMAPX_PRIORITY_SYNC_MESSAGE, error);
92
 
 
93
 
@@ -5172,13 +5169,9 @@ camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, Cam
94
 
 
95
 
        /* chen cleanup this later */
96
 
        uid = imapx_get_temp_uid ();
97
 
-       stream = camel_data_cache_add (ifolder->cache, "new", uid, NULL);
98
 
+       stream = camel_data_cache_add (ifolder->cache, "new", uid, error);
99
 
        if (stream == NULL) {
100
 
-               g_set_error (
101
 
-                       error, G_IO_ERROR,
102
 
-                       g_io_error_from_errno (errno),
103
 
-                       _("Cannot create spool file: %s"),
104
 
-                       g_strerror (errno));
105
 
+               g_prefix_error (error, _("Cannot create spool file: "));
106
 
                g_free (uid);
107
 
                return FALSE;
108
 
        }
109
 
--
110
 
cgit v0.8.3.1