From: Frédéric Marchal Date: Tue, 1 Nov 2011 12:56:16 +0000 (+0000) Subject: Delete the unused user's directories X-Git-Tag: v2.3.2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c649f9b73e808ffb34b26034d9bdb564b35d5697;p=thirdparty%2Fsarg.git Delete the unused user's directories 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. --- diff --git a/html.c b/html.c index af07349..4950790 100644 --- 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);