aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/UserInfo.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/UserInfo.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/UserInfo.pm')
-rw-r--r--IkiWiki/UserInfo.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/IkiWiki/UserInfo.pm b/IkiWiki/UserInfo.pm
index 115a263ce..02c27991c 100644
--- a/IkiWiki/UserInfo.pm
+++ b/IkiWiki/UserInfo.pm
@@ -15,12 +15,19 @@ sub userinfo_retrieve () { #{{{
sub userinfo_store ($) { #{{{
my $userinfo=shift;
+ my $newfile="$config{wikistatedir}/userdb.new";
my $oldmask=umask(077);
- my $ret=Storable::lock_store($userinfo, "$config{wikistatedir}/userdb");
+ my $ret=Storable::lock_store($userinfo, $newfile);
umask($oldmask);
+ if (defined $ret && $ret) {
+ if (! rename($newfile, "$config{wikistatedir}/userdb")) {
+ unlink($newfile);
+ $ret=undef;
+ }
+ }
return $ret;
} #}}}
-
+
sub userinfo_get ($$) { #{{{
my $user=shift;
my $field=shift;