From aff09a636cc3f39407b645618d4b1259bd292b75 Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Sun, 27 Jun 2010 11:21:39 +0200 Subject: [PATCH] experimental batch_update() and a new rrr-init which uses it --- bin/rrr-init | 6 +++++- lib/File/Rsync/Mirror/Recentfile.pm | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/rrr-init b/bin/rrr-init index a161c2c..5a5a193 100644 --- a/bin/rrr-init +++ b/bin/rrr-init @@ -78,9 +78,13 @@ my $rf = File::Rsync::Mirror::Recentfile->new verbose => $Opt{verbose}, ); +my @batch; foreach my $file ( map {$_->[1]} sort {$a->[0] <=> $b->[0]} map {[-M $_, $_]} File::Find::Rule->new->file->in($rootdir) ) { - $rf->update(File::Spec->rel2abs($file),"new"); + my $path = File::Spec->rel2abs($file); + my $epoch = (stat $path)[9]; + push @batch, {path=>$path,type=>"new",epoch=>$epoch}; } +$rf->batch_update(\@batch); __END__ diff --git a/lib/File/Rsync/Mirror/Recentfile.pm b/lib/File/Rsync/Mirror/Recentfile.pm index e9dcda9..782c58b 100644 --- a/lib/File/Rsync/Mirror/Recentfile.pm +++ b/lib/File/Rsync/Mirror/Recentfile.pm @@ -1985,6 +1985,14 @@ sub update { $self->_assert_symlink; $self->unlock; } +sub batch_update { + my($self,$batch) = @_; + $self->lock; + my $ctx = $self->_locked_batch_update($batch); + $self->write_recent($ctx->{recent}) if $ctx->{something_done}; + $self->_assert_symlink; + $self->unlock; +} sub _locked_batch_update { my($self,$batch) = @_; my $something_done = 0; -- 2.11.4.GIT