+2007-03-31 16:07 -0700 Brendan Cully <brendan@kublai.com> (bf208df92829)
+
+ * imap/command.c, imap/imap.c: Allow IMAP FCC to reconnect if
+ append fails (closes: #890)
+
+ * mh.c: Always set up data pointer in mh_read_dir, not just when
+ allocating context
+
2007-03-30 21:26 -0700 Daniel Burrows <dburrows@debian.org> (d5ab883ef90a)
* hcache.c: Fix handling of DB4 hcache open failure. (closes: #2714)
return fp;
}
-FILE* mutt_bcache_put(body_cache_t *bcache, const char *id)
+FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp)
{
char path[_POSIX_PATH_MAX];
FILE* fp;
if (!id || !*id || !bcache)
return NULL;
- path[0] = '\0';
- safe_strncat (path, sizeof (path), bcache->path, bcache->pathlen);
- safe_strncat (path, sizeof (path), id, mutt_strlen (id));
+ snprintf (path, sizeof (path), "%s%s%s", bcache->path, id,
+ tmp ? ".tmp" : "");
s = strchr (path + 1, '/');
while (!(fp = safe_fopen (path, "w+")) && errno == ENOENT && s)
return fp;
}
+int mutt_bcache_commit(body_cache_t* bcache, const char* id)
+{
+ char tmpid[_POSIX_PATH_MAX];
+
+ snprintf (tmpid, sizeof (tmpid), "%s.tmp", id);
+
+ return mutt_bcache_move (bcache, tmpid, id);
+}
+
int mutt_bcache_move(body_cache_t* bcache, const char* id, const char* newid)
{
char path[_POSIX_PATH_MAX];
*/
FILE* mutt_bcache_get(body_cache_t *bcache, const char *id);
-FILE* mutt_bcache_put(body_cache_t *bcache, const char *id);
+/* tmp: the returned FILE* is in a temporary location.
+ * if set, use mutt_bcache_commit to put it into place */
+FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp);
+int mutt_bcache_commit(body_cache_t *bcache, const char *id);
int mutt_bcache_move(body_cache_t *bcache, const char *id, const char *newid);
int mutt_bcache_del(body_cache_t *bcache, const char *id);
int mutt_bcache_exists(body_cache_t *bcache, const char *id);
return NULL;
idata->bcache = msg_cache_open (idata);
- snprintf (id, sizeof (id), "%u-%u.tmp", idata->uid_validity, HEADER_DATA(h)->uid);
- return mutt_bcache_put (idata->bcache, id);
+ snprintf (id, sizeof (id), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid);
+ return mutt_bcache_put (idata->bcache, id, 1);
}
static int msg_cache_commit (IMAP_DATA* idata, HEADER* h)
{
char id[_POSIX_PATH_MAX];
- char newid[_POSIX_PATH_MAX];
if (!idata || !h)
return -1;
idata->bcache = msg_cache_open (idata);
- snprintf (id, sizeof (id), "%u-%u.tmp", idata->uid_validity, HEADER_DATA(h)->uid);
- snprintf (newid, sizeof (newid), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid);
+ snprintf (id, sizeof (id), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid);
- return mutt_bcache_move (idata->bcache, id, newid);
+ return mutt_bcache_commit (idata->bcache, id);
}
int imap_cache_del (IMAP_DATA* idata, HEADER* h)
}
/* close POP mailbox */
-void pop_close_mailbox (CONTEXT *ctx)
+int pop_close_mailbox (CONTEXT *ctx)
{
POP_DATA *pop_data = (POP_DATA *)ctx->data;
if (!pop_data)
- return;
+ return 0;
pop_logout (ctx);
mutt_bcache_close (&pop_data->bcache);
- return;
+ return 0;
}
/* fetch message from POP server */
M_PROGRESS_SIZE, NetInc, h->content->length + h->content->offset - 1);
/* see if we can put in body cache; use our cache as fallback */
- if (!(msg->fp = mutt_bcache_put (pop_data->bcache, h->data)))
+ if (!(msg->fp = mutt_bcache_put (pop_data->bcache, h->data, 1)))
{
/* no */
bcache = 0;
/* if RETR failed (e.g. connection closed), be sure to remove either
* the file in bcache or from POP's own cache since the next iteration
* of the loop will re-attempt to put() the message */
- if (bcache)
- mutt_bcache_del (pop_data->bcache, h->data);
- else
+ if (!bcache)
unlink (path);
if (ret == -2)
/* Update the header information. Previously, we only downloaded a
* portion of the headers, those required for the main display.
*/
- if (!bcache)
+ if (bcache)
+ mutt_bcache_commit (pop_data->bcache, h->data);
+ else
{
cache->index = h->index;
cache->path = safe_strdup (path);
int pop_open_mailbox (CONTEXT *);
int pop_sync_mailbox (CONTEXT *, int *);
int pop_fetch_message (MESSAGE *, CONTEXT *, int);
-void pop_close_mailbox (CONTEXT *);
+int pop_close_mailbox (CONTEXT *);
void pop_fetch_mail (void);
#endif