65 |
$debug = $opt{v}; |
$debug = $opt{v}; |
66 |
} |
} |
67 |
|
|
68 |
|
#---- subs ---- |
69 |
|
|
70 |
|
sub fmt_time { |
71 |
|
my $t = shift || return; |
72 |
|
my $out = ""; |
73 |
|
my ($ss,$mm,$hh) = gmtime($t); |
74 |
|
$out .= "${hh}h" if ($hh); |
75 |
|
$out .= sprintf("%02d:%02d", $mm,$ss); |
76 |
|
return $out; |
77 |
|
} |
78 |
|
|
79 |
|
sub curr_time { |
80 |
|
return strftime($t_fmt,localtime()); |
81 |
|
} |
82 |
|
|
83 |
|
#---- /subs ---- |
84 |
|
|
85 |
## update index ## |
## update index ## |
86 |
if ($opt{i}) { |
if ($opt{i}) { |
87 |
|
|
88 |
print "updating HyperEstraier files "; |
print curr_time," updating HyperEstraier: files"; |
89 |
|
|
90 |
|
my $t = time(); |
91 |
|
|
92 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
93 |
SELECT |
SELECT |
94 |
files.id AS fid, |
files.id AS fid, |
95 |
hosts.name AS hname, |
hosts.name AS hname, |
96 |
shares.name AS sname, |
shares.name AS sname, |
97 |
shares.share AS sharename, |
-- shares.share AS sharename, |
98 |
files.backupNum AS backupNum, |
files.backupnum AS backupnum, |
99 |
files.name AS filename, |
-- files.name AS filename, |
100 |
files.path AS filepath, |
files.path AS filepath, |
101 |
files.date AS date, |
files.date AS date, |
102 |
files.type AS filetype, |
files.type AS filetype, |
103 |
files.size AS size, |
files.size AS size, |
104 |
files.shareid AS shareid |
files.shareid AS shareid, |
105 |
|
backups.date AS backup_date |
106 |
FROM files |
FROM files |
107 |
INNER JOIN shares ON files.shareID=shares.ID |
INNER JOIN shares ON files.shareID=shares.ID |
108 |
INNER JOIN hosts ON hosts.ID = shares.hostID |
INNER JOIN hosts ON hosts.ID = shares.hostID |
110 |
}); |
}); |
111 |
|
|
112 |
$sth->execute(); |
$sth->execute(); |
113 |
|
my $results = $sth->rows; |
114 |
|
|
115 |
my $dot = int($sth->rows / 15); |
my $dot = int($results / 15); |
116 |
|
|
117 |
print $sth->rows, " files ($dot/#) "; |
print " $results ($dot/#)"; |
118 |
|
|
119 |
sub fmt_date { |
sub fmt_date { |
120 |
my $t = shift || return; |
my $t = shift || return; |
124 |
} |
} |
125 |
|
|
126 |
my $i = 0; |
my $i = 0; |
127 |
my $max = int($sth->rows / $dot); |
my $max = int($results / $dot); |
128 |
|
|
129 |
$index_path = $TopDir . '/' . $index_path; |
$index_path = $TopDir . '/' . $index_path; |
130 |
$index_path =~ s#//#/#g; |
$index_path =~ s#//#/#g; |
131 |
|
|
132 |
print "index $index_path..."; |
print " index $index_path..."; |
133 |
use HyperEstraier; |
use HyperEstraier; |
134 |
my $db = HyperEstraier::Database->new(); |
my $db = HyperEstraier::Database->new(); |
135 |
$db->open($index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT); |
$db->open($index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT); |
143 |
# add attributes to the document object |
# add attributes to the document object |
144 |
$doc->add_attr('@uri', 'file:///' . $row->{'fid'}); |
$doc->add_attr('@uri', 'file:///' . $row->{'fid'}); |
145 |
|
|
146 |
foreach my $c (qw/fid hname sname sharename backupNum filename filepath shareid/) { |
foreach my $c (@{ $sth->{NAME} }) { |
147 |
$doc->add_attr($c, $row->{$c}) if ($row->{$c}); |
$doc->add_attr($c, $row->{$c}) if ($row->{$c}); |
148 |
} |
} |
149 |
|
|
150 |
$doc->add_attr('date', fmt_date($row->{'date'})); |
#$doc->add_attr('@cdate', fmt_date($row->{'date'})); |
151 |
|
|
152 |
# add the body text to the document object |
# add the body text to the document object |
153 |
my $path = $row->{'filepath'}; |
my $path = $row->{'filepath'}; |
170 |
|
|
171 |
print "sync"; |
print "sync"; |
172 |
$db->sync(); |
$db->sync(); |
173 |
print " close\n"; |
print " close"; |
174 |
$db->close(); |
$db->close(); |
175 |
|
|
176 |
|
my $dur = (time() - $t) || 1; |
177 |
|
printf(" [%.2f/s dur: %s]\n", |
178 |
|
( $results / $dur ), |
179 |
|
fmt_time($dur) |
180 |
|
); |
181 |
|
|
182 |
exit; |
exit; |
183 |
} |
} |
184 |
|
|
318 |
VALUES (?,?,?,?,?,?,?) |
VALUES (?,?,?,?,?,?,?) |
319 |
}); |
}); |
320 |
|
|
|
sub fmt_time { |
|
|
my $t = shift || return; |
|
|
my $out = ""; |
|
|
my ($ss,$mm,$hh) = gmtime($t); |
|
|
$out .= "${hh}h" if ($hh); |
|
|
$out .= sprintf("%02d:%02d", $mm,$ss); |
|
|
return $out; |
|
|
} |
|
|
|
|
321 |
foreach my $host_key (keys %{$hosts}) { |
foreach my $host_key (keys %{$hosts}) { |
322 |
|
|
323 |
my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key"; |
my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key"; |
373 |
next if ($count > 0); |
next if ($count > 0); |
374 |
|
|
375 |
# dump some log |
# dump some log |
376 |
print strftime($t_fmt,localtime())," ", $share; |
print curr_time," ", $share; |
377 |
|
|
378 |
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
379 |
|
|