]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 208714: Make checksetup.pl move $datadir/template when it can't delete it
authormkanat%bugzilla.org <>
Thu, 20 Aug 2009 05:55:05 +0000 (05:55 +0000)
committermkanat%bugzilla.org <>
Thu, 20 Aug 2009 05:55:05 +0000 (05:55 +0000)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat

Bugzilla/Template.pm
template/en/default/setup/strings.txt.pl

index d897cd946a9117180bf8489a316c6c9085dbf3d2..05ce2dde582e9308b756e0b089942eb8d93e48aa 100644 (file)
@@ -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: $!";
         }
     }
 
index 6766bac7894a353eb968dfaf8519aa05a7e34e70..bbccf6339ba6a5a7947be656463526a116ed9ea9 100644 (file)
@@ -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...",
 );