1 #!/usr/bin/perl -- -*- mode: cperl -*-
5 rrr-dirtyupdate - add a file with an old timestamp to the dataset
9 rrr-dirtyupdate [options] principalfile file [epoch]
11 rrr-dirtyupdate --force principalfile
19 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 Inject a delete event. If the epoch argument is missing, find the
24 according file event and set epoch to that epoch plus 1.
28 Force this run even without any arguments. E.g. just for the side
29 effect of running an aggregate call.
33 Prints a brief message and exists.
43 When you later discover missing files...
45 The principalfile argument is the path to local principal recentfile.
47 The file argument is a relative path calculated from the localroot
48 directory of the recentfile object.
50 If the epoch argument is missing it is calculated from the
51 modification time of the file.
55 This is slow: it calls aggregate twice with force which took 2 x 10-20 seconds on PAUSE.
63 use File
::Find
qw(find);
64 use lib
"/home/k/sources/rersyncrecent/lib";
65 use File
::Rsync
::Mirror
::Recent
;
68 use Pod
::Usage
qw(pod2usage);
79 my $aggregate_only = 0;
86 } elsif (@ARGV >= 3) {
90 my($principal,$file,$epoch) = @ARGV;
91 my $recc = File
::Rsync
::Mirror
::Recent
->new
92 (local => $principal);
93 my($rf) = $recc->principal_recentfile;
94 my $abs_file = File
::Spec
->catfile($rf->localroot,$file);
96 unless ($aggregate_only) {
97 unless (defined $epoch) {
99 my $news = $recc->news(contains
=> { path
=> $file });
101 print "Found file:\n", YAML
::Syck
::Dump
$news;
102 $epoch = $news->[0]{epoch
} + 1;
104 die "didn't find '$file' in this recentfile collection";
107 my(@stat) = stat $abs_file or die "Could not stat '$abs_file': $!";
111 my $type = $Opt{delete} ?
"delete" : "add";
112 $rf->update($abs_file,$type,$epoch);
114 warn localtime()." starting first aggregate\n";
115 $rf->aggregate(force
=> 1);
116 warn localtime()." starting second aggregate\n";
117 $rf->aggregate(force
=> 1);
118 warn localtime()." finished\n";
127 # cperl-indent-level: 4