summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-06-11 19:05:12 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-06-11 19:05:12 +0000
commit2684f2c5af343e06a51573277b39261dcd3d0956 (patch)
tree45e57cf079c18096f5139f96beeab57eeab05c19 /mh.c
parentd018703d17dec5b7d0fab80eaef82edc73b29d1c (diff)
Fix some issues with synching of maildir/mh folders. Problems noted
by Byrial Jensen.
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/mh.c b/mh.c
index 46cfbab0..2d970d21 100644
--- a/mh.c
+++ b/mh.c
@@ -477,6 +477,9 @@ int maildir_commit_message (CONTEXT *ctx, MESSAGE *msg, HEADER *hdr)
char full[_POSIX_PATH_MAX];
char *s;
+ if (safe_fclose (&msg->fp) != 0)
+ return -1;
+
/* extract the subdir */
s = strrchr (msg->path, '/') + 1;
strfcpy (subdir, s, 4);
@@ -529,6 +532,9 @@ int mh_commit_message (CONTEXT *ctx, MESSAGE *msg, HEADER *hdr)
char path[_POSIX_PATH_MAX];
char tmp[16];
+ if (safe_fclose (&msg->fp) != 0)
+ return -1;
+
if ((dirp = opendir (ctx->path)) == NULL)
{
mutt_perror (ctx->path);
@@ -596,6 +602,7 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
MESSAGE *dest;
int rc;
+ short restore = 1;
char oldpath[_POSIX_PATH_MAX];
char newpath[_POSIX_PATH_MAX];
char partpath[_POSIX_PATH_MAX];
@@ -621,7 +628,10 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
mx_close_message (&dest);
if (rc == 0)
+ {
unlink (oldpath);
+ restore = 0;
+ }
/*
* Try to move the new message to the old place.
@@ -645,9 +655,10 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
mutt_str_replace (&h->path, partpath);
}
}
- else mx_close_message (&dest);
+ else
+ mx_close_message (&dest);
- if (rc == -1)
+ if (rc == -1 && restore)
{
h->content->offset = old_body_offset;
h->content->length = old_body_length;