-rw-r--r-- | kmicromail/libetpan/mh/mailmh.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/kmicromail/libetpan/mh/mailmh.c b/kmicromail/libetpan/mh/mailmh.c index 119f217..5e2b4cc 100644 --- a/kmicromail/libetpan/mh/mailmh.c +++ b/kmicromail/libetpan/mh/mailmh.c @@ -608,4 +608,5 @@ static int mailmh_folder_alloc_msg(struct mailmh_folder * folder, char * new_filename; size_t len; + struct stat f_stat; len = strlen(folder->fl_filename) + 20; @@ -616,14 +617,17 @@ static int mailmh_folder_alloc_msg(struct mailmh_folder * folder, max = folder->fl_max_index + 1; + //fprintf(stderr,"mailmh_folder_alloc_msg filename: %s \n", filename); k = 0; while (k < MAX_TRY_ALLOC) { snprintf(new_filename, len, "%s%c%lu", folder->fl_filename, MAIL_DIR_SEPARATOR, (unsigned long) (max + k)); - - if (link(filename, new_filename) == 0) { + //fprintf(stderr,"mailmh_folder_alloc_msg new_filename: %s \n", new_filename); + if ( stat( new_filename, &f_stat ) == -1 ) { + // if (link(filename, new_filename) == 0) { int r; - + //fprintf(stderr,"filename found \n"); + //unlink(filename); + rename (filename,new_filename ); free(new_filename); - unlink(filename); if (k > MAX_TRY_ALLOC / 2) { |