From d4c61b72813b880d86b316770f2e3819a6428202 Mon Sep 17 00:00:00 2001 From: joey Date: Thu, 15 Feb 2007 02:22:08 +0000 Subject: * 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. --- IkiWiki/UserInfo.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'IkiWiki/UserInfo.pm') 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; -- cgit v1.2.3