]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't process the download report if no entry was written in the log file
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 14 Mar 2012 06:41:24 +0000 (07:41 +0100)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 14 Mar 2012 06:41:24 +0000 (07:41 +0100)
If the download.int_unsort file doesn't exist, the sort command fails and sarg
abort the process.

With this patch, it simply continues the processing optionaly printing an
information message.

Now, it is an error if the sorted file doesn't exists. In previous versions, it
was just a warning.

download.c

index b1fd04c13748a2cf019c3d059544857bdebafb45..83b4191088c20f0fb469e40ca041b59e6ad7a404 100644 (file)
@@ -110,6 +110,11 @@ void download_report(void)
        struct userinfostruct *uinfo;
        struct tm t;
 
+       if (!ndownload) {
+               if (debugz) debugaz(_("No downloaded files to report\n"));
+               return;
+       }
+
        ouser[0]='\0';
        ouser2[0]='\0';
 
@@ -117,8 +122,8 @@ void download_report(void)
        snprintf(report_in,sizeof(report_in),"%s/download.int_log",tmp);
        download_sort(report_in);
        if(access(report_in, R_OK) != 0) {
-               if (debugz) debugaz(_("Downloaded files report not generated as it is empty\n"));
-               return;
+               debugaz(_("Sorted file doesn't exist (to produce the download report)\n"));
+               exit(EXIT_FAILURE);
        }
 
        // produce the report.