From 41dc8026e6af90549a07056c05928f7b9517075c Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Wed, 8 Oct 2008 22:54:04 +0200 Subject: [PATCH] fix buglets, unify the name of the variable to $pathdb and move the secondary ttl line up --- Todo | 11 +++++++++++ lib/File/Rsync/Mirror/Recent.pm | 26 +++++++++++++++----------- lib/File/Rsync/Mirror/Recentfile.pm | 4 ++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Todo b/Todo index 24f332d..8c475f4 100644 --- a/Todo +++ b/Todo @@ -1,5 +1,16 @@ 2008-10-08 Andreas J. Koenig + * current bugs: the pathdb seems to get no reset, the seeding of the + secondaryttl stuff seems not to have an effect. Have helped myself with + a rand(10), need to fix this back. So not checked in. Does the rand + thing even help? + + The rand thing helps. The secondaryttl stuff was in the wrong line, + fixed now. + + The pathdb stuff was because I called either _pathdb or __pathdb on the + wrong object. Fixed now. + * do not forget the dirtymark! * It's not so beautiful if we never fetch the recentfiles that are not diff --git a/lib/File/Rsync/Mirror/Recent.pm b/lib/File/Rsync/Mirror/Recent.pm index 59ac62b..be352d3 100644 --- a/lib/File/Rsync/Mirror/Recent.pm +++ b/lib/File/Rsync/Mirror/Recent.pm @@ -325,11 +325,11 @@ sub _pathdb { if ($set) { $self->__pathdb ($set); } - my $db = $self->__pathdb; - unless (defined $db) { + my $pathdb = $self->__pathdb; + unless (defined $pathdb) { $self->__pathdb(+{}); } - return $db; + return $self->__pathdb; } =head2 $recentfile = $obj->principal_recentfile () @@ -373,18 +373,18 @@ recentfiles exist or have been read. They are just bare objects. sub recentfiles { my($self) = @_; - my $rfs = $self->_recentfiles; + my $rfs = $self->_recentfiles; return $rfs if defined $rfs; - my $rf0 = $self->principal_recentfile; - my $db = +{}; - $rf0->_pathdb ( $db ); + my $rf0 = $self->principal_recentfile; + my $pathdb = $self->_pathdb; + $rf0->_pathdb ($pathdb); my $aggregator = $rf0->aggregator; - my @rf = $rf0; + my @rf = $rf0; for my $agg (@$aggregator) { my $nrf = $rf0->_sparse_clone; $nrf->interval ( $agg ); $nrf->have_mirrored ( 0 ); - $nrf->_pathdb ( $db ); + $nrf->_pathdb ( $pathdb ); push @rf, $nrf; } $self->_recentfiles(\@rf); @@ -452,6 +452,7 @@ sub rmirror { ( $file, {i => $i, + options => \%options, self => $self, time => time, uptodate => {map {($_=>$rfs->[$_]->uptodate)} 0..$#$rfs}, @@ -499,7 +500,10 @@ sub rmirror { $self->_max_one_state(0); if ($rfs->[-1]->uptodate) { if ($options{loop}) { - $self->_pathdb(+{}); + my $pathdb = $self->_pathdb(); + for my $k (keys %$pathdb) { + delete $pathdb->{$k}; + } if (my $ttl = $self->secondaryttl) { if (time > $secondary_timestamp+$ttl) { my @names; @@ -508,8 +512,8 @@ sub rmirror { push @names, $xrf->interval; } warn "DEBUG: seeded @names\n"; + $secondary_timestamp = time; } - $secondary_timestamp = time; } } else { last LOOP; diff --git a/lib/File/Rsync/Mirror/Recentfile.pm b/lib/File/Rsync/Mirror/Recentfile.pm index ff12bad..f952213 100644 --- a/lib/File/Rsync/Mirror/Recentfile.pm +++ b/lib/File/Rsync/Mirror/Recentfile.pm @@ -1100,10 +1100,10 @@ sub _empty_xcollector { } sub _register_path { - my($self,$db,$coll,$activity) = @_; + my($self,$pathdb,$coll,$activity) = @_; my $time = time; for my $item (@$coll) { - $db->{$item->{path}} = + $pathdb->{$item->{path}} = { recentepoch => $item->{epoch}, ($activity."_on") => $time, -- 2.11.4.GIT