From fb5a11226b8c5c65df7afa90547e6ddfe711a839 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Sat, 26 Nov 2011 14:18:04 +0100 Subject: Bug 368250: collectstats.pl creates files with wrong ownership r/a=mkanat --- collectstats.pl | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'collectstats.pl') diff --git a/collectstats.pl b/collectstats.pl index 007669fad..1487e5a72 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"; 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,13 @@ 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"; - + close DATA; - chmod 0640, $file; } } -- cgit v1.2.3-24-g4f1b