pilerimport don't show an error if cannot write to current dir

Issue #418 resolved
Former user created an issue

I'm importing several mbox files using pilerimport -m mboxfile.

But if the current dir is not writable for piler user it process the mbox file, no message is imported and no error is shown.

I changed pilerimport.c to show an error if it cannot write to current dir:

*** a/pilerimport.c 2014-10-01 20:01:27.000000000 -0300
--- b/pilerimport.c 2014-10-01 20:03:50.000000000 -0300
***************
*** 76,95 ****
--- 76,99 ----

              if(data->quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout);
           }

           snprintf(fname, sizeof(fname)-1, "%ld-%d", t, tot_msgs);
           f = fopen(fname, "w+");
           continue;
        }

        if(f) fprintf(f, "%s", buf);
+       else {
+          printf("cannot write temp file to current dir.");
+          return ERR;
+       }
     }

     if(f){
        fclose(f);
        rc = import_message(fname, sdata, data, cfg);
        if(rc == ERR){
           printf("error importing: '%s'\n", fname);
           ret = ERR;
        }
        else unlink(fname);

Comments (3)

  1. Janos SUTO repo owner

    This seems to be a generic issue, so I've added a feature check when pilerimport runs: it checks whether it can write the current directory, if not, then it prints an error and quits. I've just committed the patch to the master branch, please try it.

  2. Log in to comment