]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Delete the unused user's directories
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 1 Nov 2011 12:56:16 +0000 (12:56 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 1 Nov 2011 12:56:16 +0000 (12:56 +0000)
Some directories are created to store the user's data but if they end up
not being used, they are deleted along with their content. It saves
space on the disk.

A nicer fix would be not to create the directories and their content in
the first place but I'll keep that for the next release.

html.c

diff --git a/html.c b/html.c
index af073490b28f8af70e2678c81cd82bc56004a2f2..495079038f3e59554b8fa75b6e59c4dd68f89bf6 100644 (file)
--- a/html.c
+++ b/html.c
@@ -85,21 +85,23 @@ void htmlrel(void)
                exit(EXIT_FAILURE);
        }
        while ( (uinfo = userinfo_advancescan(uscan)) != NULL ) {
-               if (!uinfo->topuser) {
-                       continue;
-               }
-               tmpsort(uinfo);
-
                if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,uinfo->filename)>=sizeof(warea)) {
                        debuga(_("Destination directory too long: %s/%s\n"),outdirname,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
+               if (!uinfo->topuser) {
+                       //! \todo Instead of deleting the supernumerary directories, don't create them in the first place.
+                       unlinkdir(warea,0);
+                       continue;
+               }
+
                if (access(warea, R_OK) != 0) {
                        if (mkdir(warea,0755)) {
                                debuga(_("Cannot create directory %s - %s\n"),warea,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                }
+               tmpsort(uinfo);
 
                report_day(uinfo);
                greport_day(uinfo);