use of localtime without parens
[rersyncrecent.git] / bin / rrr-dirtyupdate
blob1c57602a9ac3dbed81ed73e68941e593e5ca3b16
1 #!/usr/bin/perl -- -*- mode: cperl -*-
3 =head1 NAME
5 rrr-dirtyupdate - add a file with an old timestamp to the dataset
7 =head1 SYNOPSIS
9 rrr-dirtyupdate [options] file epoch
11 =head1 OPTIONS
13 =over 8
15 =cut
17 my @opt = <<'=back' =~ /B<--(\S+)>/g;
19 =item B<--dry-run!>
21 (TBD) Do not really run the command, ...
23 =item B<--help|h>
25 Prints a brief message and exists.
27 =item B<--verbose|v+>
29 More feedback.
31 =back
33 =head1 DESCRIPTION
35 When you later discover missing files...
37 =head1 BUGS
39 This is slow: it calls aggregate twice with force which took 2 x 10-15 seconds on PAUSE.
41 =cut
44 use strict;
45 use warnings;
47 use File::Find qw(find);
48 use File::Rsync::Mirror::Recent;
49 use Getopt::Long;
50 use Pod::Usage qw(pod2usage);
52 our %Opt;
53 GetOptions(\%Opt,
54 @opt,
55 ) or pod2usage(1);
57 if ($Opt{help}) {
58 pod2usage(0);
61 unless (@ARGV) {
62 pod2usage(1);
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",
75 unless ($rf) {
76 die "ALERT: Could not create an rf: $@";
78 my $sleep = 2;
79 warn "prove of concept for one file only. Last chance to hit ^C now to interrupt. sleeping $sleep";
80 sleep $sleep;
81 my %recfiles;
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;
91 my %diskfiles;
92 find({
93 wanted => sub {
94 my @stat = lstat $_;
95 return if -l _;
96 return unless -f _;
97 return if delete $recfiles{$File::Find::name};
98 $diskfiles{$File::Find::name} = $stat[9];
100 no_chdir => 1,
102 "/home/ftp/pub/PAUSE/authors/id"
105 ENDLESS: while () {
106 last ENDLESS unless %diskfiles;
107 my @files;
108 CENTOPED: for my $k (sort {$diskfiles{$a} <=> $diskfiles{$b}} keys %diskfiles) {
109 push @files, $k;
110 delete $diskfiles{$k};
111 last CENTOPED if @files >= 263;
113 last ENDLESS unless @files;
114 my $totalfiles = keys %diskfiles;
115 my $files = @files;
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";
131 sleep 45;
134 __END__
137 # Local Variables:
138 # mode: cperl
139 # coding: utf-8
140 # cperl-indent-level: 4
141 # End: