diff options
author | Frédéric Buclin <LpSolit@gmail.com> | 2011-11-26 14:12:47 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2011-11-26 14:12:47 +0100 |
commit | 7a9a9a8f1e4c1d17ff58fb0bbae9513c85986488 (patch) | |
tree | 7ffcce8ab7c299883ef3db554d3759835bf24057 /collectstats.pl | |
parent | Bug 255606: Do not let buglist.cgi return all bugs by default (diff) | |
download | bugzilla-7a9a9a8f1e4c1d17ff58fb0bbae9513c85986488.tar.gz bugzilla-7a9a9a8f1e4c1d17ff58fb0bbae9513c85986488.tar.bz2 bugzilla-7a9a9a8f1e4c1d17ff58fb0bbae9513c85986488.zip |
Bug 368250: collectstats.pl creates files with wrong ownership
r/a=mkanat
Diffstat (limited to 'collectstats.pl')
-rwxr-xr-x | collectstats.pl | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/collectstats.pl b/collectstats.pl index 007669fad..be51d9b8d 100755 --- a/collectstats.pl +++ b/collectstats.pl @@ -41,6 +41,7 @@ use Bugzilla::Search; use Bugzilla::User; use Bugzilla::Product; use Bugzilla::Field; +use Bugzilla::Install::Filesystem qw(fix_dir_permissions); my %switch; GetOptions(\%switch, 'help|h', 'regenerate'); @@ -139,32 +140,28 @@ my $tstart = time; my @myproducts = Bugzilla::Product->get_all; unshift(@myproducts, "-All-"); -foreach (@myproducts) { - my $dir = "$datadir/mining"; - - &check_data_dir ($dir); +my $dir = "$datadir/mining"; +if (!-d $dir) { + mkdir $dir or die "mkdir $dir failed: $!"; + fix_dir_permissions($dir); +} +foreach (@myproducts) { if ($switch{'regenerate'}) { regenerate_stats($dir, $_, \%bug_resolution, \%bug_status, \%removed); } else { &collect_stats($dir, $_); } } +# Fix permissions for all files in mining/. +fix_dir_permissions($dir); + my $tend = time; # Uncomment the following line for performance testing. -#print "Total time taken " . delta_time($tstart, $tend) . "\n"; +#say "Total time taken " . delta_time($tstart, $tend); CollectSeriesData(); -sub check_data_dir { - my $dir = shift; - - if (! -d $dir) { - mkdir $dir, 0755; - chmod 0755, $dir; - } -} - sub collect_stats { my $dir = shift; my $product = shift; @@ -250,7 +247,6 @@ FIN } print DATA (join '|', @row) . "\n"; close DATA; - chmod 0644, $file; } sub get_old_data { @@ -406,14 +402,12 @@ FIN foreach (@resolutions) { print DATA "|$bugcount{$_}"; } print DATA "\n"; } - + # Finish up output feedback for this product. my $tend = time; - print "\rRegenerating $product \[100.0\%] - " . - delta_time($tstart, $tend) . "\n"; - + say "\rRegenerating $product \[100.0\%] - " . delta_time($tstart, $tend); + close DATA; - chmod 0640, $file; } } |