5 rrr-update - add a file to/delete a file from the dataset
9 rrr-update [options] principalfile file
17 my @opt = <<'=back' =~ /B<--(\S+)>/g;
25 Inject a 'delete' event.
29 Does nothing, only prints what it would do.
33 Set the epoch of the file to this value. Normally epoch is set to
34 current time as a floating point value. This option can be used to
35 inject old events that have been forgotten somehow. Triggers setting
36 of the dirtymark of the whole dataset which means all slaves are
37 forced to restart their mirroring activity.
39 Be aware that this is not only costly to downstream servers, it is
40 also slow: it calls aggregate twice with force.
44 Prints a brief message and exists.
54 When you later discover missing files...
56 The principalfile argument is the path to local principal recentfile.
58 The file argument is a relative path calculated from the localroot
59 directory of the recentfile object.
68 use File
::Find
qw(find);
69 use lib
"/home/k/sources/rersyncrecent/lib";
70 use File
::Rsync
::Mirror
::Recent
;
73 use Pod
::Usage
qw(pod2usage);
88 my($principal,$file) = @ARGV;
89 my $recc = File
::Rsync
::Mirror
::Recent
->new
90 (local => $principal);
91 my($rf) = $recc->principal_recentfile;
92 my($abs_file,$rel_file);
93 if (File
::Spec
->file_name_is_absolute($file)) {
94 $rel_file = substr($file,length $rf->localroot);
98 $abs_file = File
::Spec
->catfile($rf->localroot,$file);
103 my $news = $recc->news(contains
=> { path
=> $rel_file });
105 warn "Found file:\n".YAML
::Syck
::Dump
$news;
107 die "Didn't find '$file' in this recentfile collection, giving up.";
110 } elsif ($Opt{add
}) {
111 my $news = $recc->news(contains
=> { path
=> $rel_file });
113 warn "Info: found file in index:\n".YAML
::Syck
::Dump
$news;
118 my $epoch = $Opt{epoch
};
119 if (defined $epoch) {
120 if ($Opt{"dry-run"}) {
121 warn sprintf "Would call update on directory %s with args abs_file[%s], type[%s], epoch[%s] and then aggregate with force twice.\n",
122 $rf->localroot, $abs_file, $type, $epoch;
124 $rf->update($abs_file,$type,$epoch);
125 warn localtime()." starting first aggregate\n";
126 $rf->aggregate(force
=> 1);
127 warn localtime()." starting second aggregate\n";
128 $rf->aggregate(force
=> 1);
131 if ($Opt{"dry-run"}) {
132 warn sprintf "Would call update on directory %s with args abs_file[%s], type[%s].\n",
133 $rf->localroot, $abs_file, $type, $epoch;
135 $rf->update($abs_file,$type);
146 # cperl-indent-level: 4