Emails are removed from IMAP server when using -D

Issue #593 resolved
ercpe created an issue

Emails are deleted from an IMAP server when using -r (remove after import) and -D (dry run) together, like pilerimport -i someserver -u foo -p bar -P 993 -R -r -D. When using this command line, the mails aren't imported but deleted from the remote server. I definitely expect that a argument called "dry run" prevents all destructive operations on a system.

Comments (2)

  1. Janos SUTO repo owner

    You are right. Please apply the following (fixed) diff, and recompile:

    diff --git a/src/imap.c b/src/imap.c
    index b41dcf8..bff1795 100644
    --- a/src/imap.c
    +++ b/src/imap.c
    @@ -248,7 +248,7 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
           if(rc == ERR) printf("error importing '%s'\n", filename);
           else {
    
    -         if(data->import->remove_after_import == 1){
    +         if(data->import->remove_after_import == 1 && dryrun == 0){
                 snprintf(buf, sizeof(buf)-1, "A%d STORE %d +FLAGS.SILENT (\\Deleted)\r\n", *seq, i);
                 n = write1(sd, buf, strlen(buf), use_ssl, data->ssl);
                 read_response(sd, buf, sizeof(buf), seq, data, use_ssl);
    @@ -260,7 +260,7 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
    
        }
    
    -   if(data->import->remove_after_import == 1){
    +   if(data->import->remove_after_import == 1 && dryrun == 0){
           snprintf(buf, sizeof(buf)-1, "A%d EXPUNGE\r\n", *seq);
           n = write1(sd, buf, strlen(buf), use_ssl, data->ssl);
           read_response(sd, buf, sizeof(buf), seq, data, use_ssl);
    
  2. Log in to comment