From adbaa19bac494d4c783c49fb3d143fe0e0aa3616 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 10 Jun 2002 06:25:04 +0000 Subject: some changes with commit and add_prospective_address --- Echolot/Storage/File.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'Echolot') diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm index d83f548..61cca8e 100644 --- a/Echolot/Storage/File.pm +++ b/Echolot/Storage/File.pm @@ -1,7 +1,7 @@ package Echolot::Storage::File; # (c) 2002 Peter Palfrader -# $Id: File.pm,v 1.2 2002/06/10 05:13:37 weasel Exp $ +# $Id: File.pm,v 1.3 2002/06/10 06:25:04 weasel Exp $ # =pod @@ -84,8 +84,12 @@ sub new { sub commit($) { my ($self) = @_; - return if $self->{'DELAY_COMMIT'}; + if ($self->{'DELAY_COMMIT'}) { + $self->{'COMMIT_PENDING'} = 1; + return; + }; $self->metadata_write(); + $self->{'COMMIT_PENDING'} = 0; }; sub delay_commit($) { @@ -97,7 +101,7 @@ sub enable_commit($) { my ($self) = @_; $self->{'DELAY_COMMIT'}--; - $self->commit(); + $self->commit() if ($self->{'COMMIT_PENDING'} && ! $self->{'DELAY_COMMIT'}); }; sub finish($) { @@ -357,12 +361,11 @@ sub register_pingdone($$$$$) { return 1; }; -sub add_prospective_address($$$) { - my ($self, $addr, $where) = @_; +sub add_prospective_address($$$$) { + my ($self, $addr, $reason, $additional) = @_; - push @{ $self->{'METADATA'}->{'prostective_addresses'} }, - { 'address' => $addr, - 'where' => $where }; + return 1 if defined $self->{'METADATA'}->{'addresses'}->{$addr}; + push @{ $self->{'METADATA'}->{'prospective_addresses'}{$addr} }, time().'; '. $reason. '; '. $additional; $self->commit(); }; -- cgit v1.2.3