From: Justin Erenkrantz Date: Wed, 10 Aug 2005 23:14:57 +0000 (+0000) Subject: Add -t option to htcacheclean to clean out empty directories. X-Git-Tag: 2.1.7~5^2~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5db9990f3604b607ccbded1ca6d15fb973c03b2;p=apache Add -t option to htcacheclean to clean out empty directories. * support/htcacheclean.c: Implement -t option. * docs/man/htcacheclean.8, docs/manual/programs/htcacheclean.html.en, docs/manual/programs/htcacheclean.xml: Document -t option. Justin did some minor tweaks as he agrees with Andreas and Rudiger that apr_dir_remove should return an error if the directory isn't empty; hence, remove the apr_dir_read calls. Submitted by: Colm MacCarthaigh Reviewed by: Justin Erenkrantz, Andreas Steinmetz, Rudiger Pluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@231351 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/man/htcacheclean.8 b/docs/man/htcacheclean.8 index 2ef2c73120..746a7bab3a 100644 --- a/docs/man/htcacheclean.8 +++ b/docs/man/htcacheclean.8 @@ -19,7 +19,7 @@ .el .ne 3 .IP "\\$1" \\$2 .. -.TH "HTCACHECLEAN" 8 "2004-11-10" "Apache HTTP Server" "htcacheclean" +.TH "HTCACHECLEAN" 8 "2005-08-08" "Apache HTTP Server" "htcacheclean" .SH NAME htcacheclean \- Clean up the disk cache @@ -27,10 +27,10 @@ htcacheclean \- Clean up the disk cache .SH "SYNOPSIS" .PP -\fBhtcacheclean\fR [ -\fBD\fR ] [ -\fBv\fR ] [ -\fBr\fR ] [ -\fBn\fR ] -\fBp\fR\fIpath\fR -\fBl\fR\fIlimit\fR +\fBhtcacheclean\fR [ -\fBD\fR ] [ -\fBv\fR ] [ -\fBt\fR ] [ -\fBr\fR ] [ -\fBn\fR ] -\fBp\fR\fIpath\fR -\fBl\fR\fIlimit\fR .PP -\fBhtcacheclean\fR -\fBb\fR [ -\fBn\fR ] [ -\fBi\fR ] -\fBd\fR\fIinterval\fR -\fBp\fR\fIpath\fR -\fBl\fR\fIlimit\fR +\fBhtcacheclean\fR -\fBb\fR [ -\fBn\fR ] [ -\fBt\fR ] [ -\fBi\fR ] -\fBd\fR\fIinterval\fR -\fBp\fR\fIpath\fR -\fBl\fR\fIlimit\fR .SH "SUMMARY" @@ -53,11 +53,14 @@ Do a dry run and don't delete anything\&. This option is mutually exclusive with Be verbose and print statistics\&. This option is mutually exclusive with the -d option\&. .TP -r -Clean thoroughly\&. This assumes that the Apache web server is not running (otherwise you may get garbage in the cache)\&. This option is mutually exclusive with the -d option\&. +Clean thoroughly\&. This assumes that the Apache web server is not running (otherwise you may get garbage in the cache)\&. This option is mutually exclusive with the -d option and implies the -t option\&. .TP -n Be nice\&. This causes slower processing in favour of other processes\&. htcacheclean will sleep from time to time so that (a) the disk IO will be delayed and (b) the kernel can schedule other processes in the meantime\&. .TP +-t +Delete all empty directories\&. By default only cache files are removed, however with some configurations the large number of directories created may require attention\&. If your configuration requires a very large number of directories, to the point that inode or file allocation table exhaustion may become an issue, use of this option is advised\&. +.TP -p\fIpath\fR Specify \fIpath\fR as the root directory of the disk cache\&. This should be the same value as specified with the CacheRoot directive\&. .TP diff --git a/docs/manual/programs/htcacheclean.html.en b/docs/manual/programs/htcacheclean.html.en index fbaaa64b79..0d1c4a6960 100644 --- a/docs/manual/programs/htcacheclean.html.en +++ b/docs/manual/programs/htcacheclean.html.en @@ -39,6 +39,7 @@

htcacheclean [ -D ] [ -v ] + [ -t ] [ -r ] [ -n ] -ppath @@ -46,6 +47,7 @@

htcacheclean -b [ -n ] + [ -t ] [ -i ] -dinterval -ppath @@ -71,7 +73,8 @@

-r
Clean thoroughly. This assumes that the Apache web server is not running (otherwise you may get garbage in the cache). This option - is mutually exclusive with the -d option.
+ is mutually exclusive with the -d option and implies + the -t option.
-n
Be nice. This causes slower processing in favour of other @@ -79,6 +82,14 @@ so that (a) the disk IO will be delayed and (b) the kernel can schedule other processes in the meantime.
+
-t
+
Delete all empty directories. By default only cache files are + removed, however with some configurations the large number of + directories created may require attention. If your configuration + requires a very large number of directories, to the point that + inode or file allocation table exhaustion may become an issue, use + of this option is advised.
+
-ppath
Specify path as the root directory of the disk cache. This should be the same value as specified with the CacheRoot directive.
diff --git a/docs/manual/programs/htcacheclean.xml b/docs/manual/programs/htcacheclean.xml index 19b835c87f..e021af966a 100644 --- a/docs/manual/programs/htcacheclean.xml +++ b/docs/manual/programs/htcacheclean.xml @@ -39,6 +39,7 @@

htcacheclean [ -D ] [ -v ] + [ -t ] [ -r ] [ -n ] -ppath @@ -46,6 +47,7 @@

htcacheclean -b [ -n ] + [ -t ] [ -i ] -dinterval -ppath @@ -71,7 +73,8 @@

-r
Clean thoroughly. This assumes that the Apache web server is not running (otherwise you may get garbage in the cache). This option - is mutually exclusive with the -d option.
+ is mutually exclusive with the -d option and implies + the -t option.
-n
Be nice. This causes slower processing in favour of other @@ -79,6 +82,14 @@ so that (a) the disk IO will be delayed and (b) the kernel can schedule other processes in the meantime.
+
-t
+
Delete all empty directories. By default only cache files are + removed, however with some configurations the large number of + directories created may require attention. If your configuration + requires a very large number of directories, to the point that + inode or file allocation table exhaustion may become an issue, use + of this option is advised.
+
-ppath
Specify path as the root directory of the disk cache. This should be the same value as specified with the basename); if (process_dir(d->basename, pool)) { return 1; } + + /* If asked to delete dirs, do so now. We don't care if it fails. + * If it fails, it likely means there was something else there. + */ + if (deldirs && !dryrun) { + apr_dir_remove(orig_basename, pool); + } continue; } @@ -740,8 +776,8 @@ static void usage(void) { apr_file_printf(errfile, "%s -- program for cleaning the disk cache." NL - "Usage: %s [-Dvrn] -pPATH -lLIMIT" NL - " %s [-ni] -dINTERVAL -pPATH -lLIMIT" NL + "Usage: %s [-Dvtrn] -pPATH -lLIMIT" NL + " %s [-nti] -dINTERVAL -pPATH -lLIMIT" NL NL "Options:" NL " -d Daemonize and repeat cache cleaning every INTERVAL minutes." NL @@ -756,11 +792,15 @@ static void usage(void) NL " -r Clean thoroughly. This assumes that the Apache web server is " NL " not running. This option is mutually exclusive with the -d" NL - " option." NL + " option and implies -t." NL NL " -n Be nice. This causes slower processing in favour of other" NL " processes." NL NL + " -t Delete all empty directories. By default only cache files are" NL + " removed, however with some configurations the large number of" NL + " directories created may require attention." NL + NL " -p Specify PATH as the root directory of the disk cache." NL NL " -l Specify LIMIT as the total disk cache size limit. Attach 'K'" NL @@ -803,6 +843,7 @@ int main(int argc, const char * const argv[]) verbose = 0; realclean = 0; benice = 0; + deldirs = 0; intelligent = 0; previous = 0; /* avoid compiler warning */ proxypath = NULL; @@ -827,7 +868,7 @@ int main(int argc, const char * const argv[]) apr_getopt_init(&o, pool, argc, argv); while (1) { - status = apr_getopt(o, "iDnvrd:l:L:p:", &opt, &arg); + status = apr_getopt(o, "iDnvrtd:l:L:p:", &opt, &arg); if (status == APR_EOF) { break; } @@ -856,6 +897,13 @@ int main(int argc, const char * const argv[]) } benice = 1; break; + + case 't': + if (deldirs) { + usage(); + } + deldirs = 1; + break; case 'v': if (verbose) { @@ -869,6 +917,7 @@ int main(int argc, const char * const argv[]) usage(); } realclean = 1; + deldirs = 1; break; case 'd':