On Mon, Dec 02, 2002 at 11:53:16AM +0000, Mark Fowler wrote:

[SNIP]

>  my $fh = IO::AtomicFile->new("foo",">")
>     or die "Can't open 'foo': $!";
> 
>  eval
>  {
>    print {$fh} $self->bar();
>    print {$fh} $self->baz();
>    print {$fh} $self->buzz();
>    close $fh;
>  };
> 
>  if ($@)
>  {
>    $fh->delete;
>    ... other error handling code ...
>  }
> 
> (obviously bar, baz and buzz throw exceptions if there's any problems)

But print() and close() don't throw exceptions if the hard disk fills
up, so in that case you'd end up renaming a partial file into place.

Even if you add a load of 'or die' to the above, the fact that
IO::AtomicFile::close discards the return value $self->SUPER::close is
going to render the update unsafe.

--
Nick

Reply via email to