lint-all-readme.pl/sanity-check.pl: be nice
[girocco.git] / toolbox / clear-all-htmlcache.pl
blob8447f03b9677cdd2a5976a4bf6f0bd05a5dfe8af
1 #!/usr/bin/perl
3 # Remove all files present in the htmlcache subdirectory of each project.
4 # A count of projects that had files to be removed is displayed.
6 use strict;
7 use warnings;
9 use lib "__BASEDIR__";
10 use Girocco::Config;
11 use Girocco::CLIUtil;
12 use Girocco::Project;
14 my $bd = $Girocco::Config::reporoot . '/';
15 my @projects = Girocco::Project::get_full_list();
16 my $progress = Girocco::CLIUtil::Progress->new(
17 scalar(@projects), "Clearing htmlcache files");
18 my $count = 0;
19 my $cleared = 0;
20 foreach (@projects) {
21 my $hcd = $bd . $_ . ".git/htmlcache";
22 opendir my $dh, $hcd or next;
23 my @files = map({/^(?![.][.]?$)(.*)$/ ? $1 : ()} readdir($dh));
24 closedir $dh;
25 unlink($hcd . "/" . $_) foreach @files;
26 @files and ++$cleared;
27 } continue {$progress->update(++$count)}
28 $progress->clear;
29 print "Projects cleared: $cleared\n";
30 exit 0