summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-08-20 07:55:05 +0200
committermkanat%bugzilla.org <>2009-08-20 07:55:05 +0200
commit4f9f364e9fbbdc6cf3eccd2c59372b9ff49e2a27 (patch)
tree72d7cf6c7e979b2e0b2d8d046d55e540b02f87a9
parentb473ef93a9194311971f9816426e1bee23b474bd (diff)
downloadbugzilla-4f9f364e9fbbdc6cf3eccd2c59372b9ff49e2a27.tar.gz
bugzilla-4f9f364e9fbbdc6cf3eccd2c59372b9ff49e2a27.tar.xz
Bug 208714: Make checksetup.pl move $datadir/template when it can't delete it
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
-rw-r--r--Bugzilla/Template.pm21
-rw-r--r--template/en/default/setup/strings.txt.pl5
2 files changed, 17 insertions, 9 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index d897cd946..05ce2dde5 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -792,17 +792,20 @@ sub precompile_templates {
if (-e "$datadir/template") {
print install_string('template_removing_dir') . "\n" if $output;
- # XXX This frequently fails if the webserver made the files, because
- # then the webserver owns the directories. We could fix that by
- # doing a chmod/chown on all the directories here.
+ # This frequently fails if the webserver made the files, because
+ # then the webserver owns the directories.
rmtree("$datadir/template");
- # Check that the directory was really removed
- if(-e "$datadir/template") {
- print "\n\n";
- print "The directory '$datadir/template' could not be removed.\n";
- print "Please remove it manually and rerun checksetup.pl.\n\n";
- exit;
+ # Check that the directory was really removed, and if not, move it
+ # into data/deleteme/.
+ if (-e "$datadir/template") {
+ print STDERR "\n\n",
+ install_string('template_removal_failed',
+ { datadir => $datadir }), "\n\n";
+ mkpath("$datadir/deleteme");
+ my $random = generate_random_password();
+ rename("$datadir/template", "$datadir/deleteme/$random")
+ or die "move failed: $!";
}
}
diff --git a/template/en/default/setup/strings.txt.pl b/template/en/default/setup/strings.txt.pl
index 6766bac78..bbccf6339 100644
--- a/template/en/default/setup/strings.txt.pl
+++ b/template/en/default/setup/strings.txt.pl
@@ -145,6 +145,11 @@ EOT
* top of the displayed list. *
EOT
template_precompile => "Precompiling templates...",
+ template_removal_failed => <<END,
+WARNING: The directory '##datadir##/template' could not be removed.
+ It has been moved into '##datadir##/deleteme', which should be
+ deleted manually to conserve disk space.
+END
template_removing_dir => "Removing existing compiled templates...",
);