From b1ad52f157699e2c55e6db811431393fc3635636 Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Thu, 16 Apr 2009 05:36:22 +0200 Subject: [PATCH] focus on delete events and be more defensive when a recentfile cannot be stat-ed --- Changes | 6 ++++++ lib/File/Rsync/Mirror/Recent.pm | 2 +- lib/File/Rsync/Mirror/Recentfile.pm | 25 +++++++++++++++++++----- lib/File/Rsync/Mirror/Recentfile/Done.pm | 2 +- lib/File/Rsync/Mirror/Recentfile/FakeBigFloat.pm | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index 758299c..2bd1e4d 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2009-04-16 Andreas J. Koenig + + * release 0.0.5 + + * focus on "delete" events that were neglected so far + 2009-04-13 Andreas J. Koenig * release 0.0.4 diff --git a/lib/File/Rsync/Mirror/Recent.pm b/lib/File/Rsync/Mirror/Recent.pm index 31a91ca..651182d 100644 --- a/lib/File/Rsync/Mirror/Recent.pm +++ b/lib/File/Rsync/Mirror/Recent.pm @@ -27,7 +27,7 @@ use Storable; use Time::HiRes qw(); use YAML::Syck; -use version; our $VERSION = qv('0.0.4'); +use version; our $VERSION = qv('0.0.5'); =head1 SYNOPSIS diff --git a/lib/File/Rsync/Mirror/Recentfile.pm b/lib/File/Rsync/Mirror/Recentfile.pm index 43b7ec1..cbc4dcc 100644 --- a/lib/File/Rsync/Mirror/Recentfile.pm +++ b/lib/File/Rsync/Mirror/Recentfile.pm @@ -30,7 +30,7 @@ use Storable; use Time::HiRes qw(); use YAML::Syck; -use version; our $VERSION = qv('0.0.1'); +use version; our $VERSION = qv('0.0.5'); use constant MAX_INT => ~0>>1; # anything better? use constant DEFAULT_PROTOCOL => 1; @@ -1277,7 +1277,7 @@ sub _mirror_perform_delayed_ops { } delete $delayed->{unlink}{$dst}; } - for my $dst (keys %{$delayed->{rmdir}}) { + for my $dst (sort {length($b) <=> length($a)} keys %{$delayed->{rmdir}}) { unless (rmdir $dst) { require Carp; Carp::cluck ( "Warning: Error on rmdir '$dst': $!" ); @@ -1475,7 +1475,7 @@ sub recent_events { $rfile_or_tempfile, ); } - return $re unless grep {defined $options{$_}} qw(after before contains max); + return $re unless grep {defined $options{$_}} qw(after before contains max skip-deletes); $self->_recent_events_handle_options ($re, \%options); } @@ -1555,8 +1555,23 @@ sub _recent_events_protocol_x { $self->$k($v); } my $re = $self->$meth ($data); - my @stat = stat $rfile_or_tempfile or die "Cannot stat '$rfile_or_tempfile': $!"; - my $minmax = { mtime => $stat[9] }; + my $minmax; + if (my @stat = stat $rfile_or_tempfile) { + $minmax = { mtime => $stat[9] }; + } else { + # defensive because ABH encountered: + +#### Sync 1239828608 (1/1/Z) temp .../authors/.FRMRecent-RECENT-Z.yaml- +#### Ydr_.yaml ... DONE +#### Cannot stat '/mirrors/CPAN/authors/.FRMRecent-RECENT-Z.yaml- +#### Ydr_.yaml': No such file or directory at /usr/lib/perl5/site_perl/ +#### 5.8.8/File/Rsync/Mirror/Recentfile.pm line 1558. +#### unlink0: /mirrors/CPAN/authors/.FRMRecent-RECENT-Z.yaml-Ydr_.yaml is +#### gone already at cpan-pause.pl line 0 + + my $LFH = $self->_logfilehandle; + print $LFH "Warning (maybe harmless): Cannot stat '$rfile_or_tempfile': $!" + } if (@$re) { $minmax->{min} = $re->[-1]{epoch}; $minmax->{max} = $re->[0]{epoch}; diff --git a/lib/File/Rsync/Mirror/Recentfile/Done.pm b/lib/File/Rsync/Mirror/Recentfile/Done.pm index 5d246c8..f19525e 100644 --- a/lib/File/Rsync/Mirror/Recentfile/Done.pm +++ b/lib/File/Rsync/Mirror/Recentfile/Done.pm @@ -13,7 +13,7 @@ File::Rsync::Mirror::Recentfile::Done - intervals of already rsynced timespans =cut -use version; our $VERSION = qv('0.0.1'); +use version; our $VERSION = qv('0.0.5'); =head1 SYNOPSIS diff --git a/lib/File/Rsync/Mirror/Recentfile/FakeBigFloat.pm b/lib/File/Rsync/Mirror/Recentfile/FakeBigFloat.pm index ff61429..89a9a6d 100644 --- a/lib/File/Rsync/Mirror/Recentfile/FakeBigFloat.pm +++ b/lib/File/Rsync/Mirror/Recentfile/FakeBigFloat.pm @@ -24,7 +24,7 @@ File::Rsync::Mirror::Recentfile::FakeBigFloat - pseudo bigfloat support =cut -use version; our $VERSION = qv('0.0.1'); +use version; our $VERSION = qv('0.0.5'); use Exporter; use base qw(Exporter); -- 2.11.4.GIT