1 #!/usr/bin/perl -- -*- mode: cperl -*-
5 rrr-dirtyupdate - add a file with an old timestamp to the dataset
9 rrr-dirtyupdate [options] file epoch
17 my @opt = <<'=back' =~ /B<--(\S+)>/g;
21 (TBD) Do not really run the command, ...
25 Prints a brief message and exists.
35 When you later discover missing files...
39 This is slow: it calls aggregate twice with force which took 2 x 10-15 seconds on PAUSE.
47 use File
::Find
qw(find);
48 use File
::Rsync
::Mirror
::Recent
;
50 use Pod
::Usage
qw(pod2usage);
65 # my($file,$epoch) = @ARGV; # XXX
67 if ($Opt{'dry-run'}) {
68 die "FIXME: not yet implemented";
71 my $rf = File
::Rsync
::Mirror
::Recentfile
->new_from_file
73 "/home/ftp/pub/PAUSE/authors/RECENT-1h.yaml",
76 die "ALERT: Could not create an rf: $@";
79 warn "prove of concept for one file only. Last chance to hit ^C now to interrupt. sleeping $sleep";
82 my $recent = File
::Rsync
::Mirror
::Recent
->new
84 local => "/home/ftp/pub/PAUSE/authors/RECENT-1h.yaml",
86 my $recentev = $recent->news();
87 for my $re (@
$recentev) {
88 $recfiles{"/home/ftp/pub/PAUSE/authors/".$re->{path
}} = 1;
97 return if delete $recfiles{$File::Find
::name
};
98 $diskfiles{$File::Find
::name
} = $stat[9];
102 "/home/ftp/pub/PAUSE/authors/id"
106 last ENDLESS
unless %diskfiles;
108 CENTOPED
: for my $k (sort {$diskfiles{$a} <=> $diskfiles{$b}} keys %diskfiles) {
110 delete $diskfiles{$k};
111 last CENTOPED
if @files >= 61;
113 last ENDLESS
unless @files;
114 my $totalfiles = keys %diskfiles;
116 warn localtime()." ($files / $totalfiles) starting\n";
117 for my $file (@files) {
118 my @stat = stat $file or die "Couldn't stat '$file': $!";
119 my $mtime = $stat[9];
120 $rf->update($file,"new",$mtime);
121 if ($file eq $files[-1]) {
122 my $slt = scalar localtime $mtime;
123 print localtime()." inj ts=$slt file=$file\n";
126 warn localtime()." starting first aggregate\n";
127 $rf->aggregate(force
=> 1);
128 warn localtime()." starting second aggregate\n";
129 $rf->aggregate(force
=> 1);
130 warn localtime()." finished\n";
140 # cperl-indent-level: 4