From 1f02bb8e0a3ebb1c98e881161995d1e712401c32 Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Fri, 10 Apr 2009 06:38:21 +0200 Subject: [PATCH] finish off delete support for rrr-dirtyupdate --- bin/rrr-dirtyupdate | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/rrr-dirtyupdate b/bin/rrr-dirtyupdate index 469a969..19310d7 100755 --- a/bin/rrr-dirtyupdate +++ b/bin/rrr-dirtyupdate @@ -44,7 +44,8 @@ When you later discover missing files... The principalfile argument is the path to local principal recentfile. -The file argument must be an existing file. +The file argument is a relative path calculated from the localroot +directory of the recentfile object. If the epoch argument is missing it is calculated from the modification time of the file. @@ -62,6 +63,7 @@ use warnings; use File::Find qw(find); use lib "/home/k/sources/rersyncrecent/lib"; use File::Rsync::Mirror::Recent; +use File::Spec; use Getopt::Long; use Pod::Usage qw(pod2usage); @@ -89,23 +91,25 @@ my($principal,$file,$epoch) = @ARGV; my $recc = File::Rsync::Mirror::Recent->new (local => $principal); my($rf) = $recc->principal_recentfile; +my $abs_file = File::Spec->catfile($rf->localroot,$file); unless ($aggregate_only) { unless (defined $epoch) { if ($Opt{delete}) { - warn "not yet implemented???"; my $news = $recc->news(contains => { path => $file }); - if ($news) { - print YAML::Syck::Dump $news; + if (@$news) { + print "Found file:\n", YAML::Syck::Dump $news; + $epoch = $news->[0]{epoch} + 1; + } else { + die "didn't find '$file' in this recentfile collection"; } - die "FIXME"; } else { - my(@stat) = stat $file or die "Could not stat '$file': $!"; + my(@stat) = stat $abs_file or die "Could not stat '$abs_file': $!"; $epoch = $stat[9]; } } my $type = $Opt{delete} ? "delete" : "add"; - $rf->update($file,$type,$epoch); + $rf->update($abs_file,$type,$epoch); } warn localtime()." starting first aggregate\n"; $rf->aggregate(force => 1); -- 2.11.4.GIT