aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/CGI.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-02-15 02:22:08 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-02-15 02:22:08 +0000
commitd4c61b72813b880d86b316770f2e3819a6428202 (patch)
treec33e8cae60810b3109400e97dc86fad8baa47027 /IkiWiki/CGI.pm
parentd9592637a962651f06f221839bbc2cfcc6789c83 (diff)
downloadikiwiki-d4c61b72813b880d86b316770f2e3819a6428202.tar
ikiwiki-d4c61b72813b880d86b316770f2e3819a6428202.tar.gz
* Many changes to make ikiwiki very resistant to write failures
including out of disk space situations. ikiwiki should never leave truncated files, and if the error occurs during a web-based file edit, the user will be given an opportunity to retry. Inspired by the many ways Moin Moin destroys itself when out of disk. :-) * Fix syslogging of errors.
Diffstat (limited to 'IkiWiki/CGI.pm')
-rw-r--r--IkiWiki/CGI.pm29
1 files changed, 25 insertions, 4 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 6c489df8d..973053427 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -252,12 +252,15 @@ sub cgi_prefs ($$) { #{{{
elsif ($form->submitted eq 'Save Preferences' && $form->validate) {
foreach my $field (qw(email subscriptions)) {
if (defined $form->field($field) && length $form->field($field)) {
- userinfo_set($user_name, $field, $form->field($field)) || error("failed to set $field");
+ userinfo_set($user_name, $field, $form->field($field)) ||
+ error("failed to set $field");
}
}
if (is_admin($user_name)) {
set_banned_users(grep { ! is_admin($_) }
- split(' ', $form->field("banned_users")));
+ split(' ',
+ $form->field("banned_users"))) ||
+ error("failed saving changes");
}
$form->text(gettext("Preferences saved."));
}
@@ -487,7 +490,25 @@ sub cgi_editpage ($$) { #{{{
$content=~s/\r\n/\n/g;
$content=~s/\r/\n/g;
- writefile($file, $config{srcdir}, $content);
+
+ $config{cgi}=0; # avoid cgi error message
+ eval { writefile($file, $config{srcdir}, $content) };
+ $config{cgi}=1;
+ if ($@) {
+ $form->field(name => "rcsinfo", value => rcs_prepedit($file),
+ force => 1);
+ $form->tmpl_param("failed_save", 1);
+ $form->tmpl_param("error_message", $@);
+ $form->field("editcontent", value => $content, force => 1);
+ $form->field(name => "comments", value => $form->field('comments'), force => 1);
+ $form->field("do", "edit)");
+ $form->tmpl_param("page_select", 0);
+ $form->field(name => "page", type => 'hidden');
+ $form->field(name => "type", type => 'hidden');
+ $form->title(sprintf(gettext("editing %s"), $page));
+ print $form->render(submit => \@buttons);
+ return;
+ }
if ($config{rcs}) {
my $message="";
@@ -616,7 +637,7 @@ sub cgi (;$$) { #{{{
email => "",
password => "",
regdate => time,
- });
+ }) || error("failed adding user");
}
}
}