+
+ my $glob = "$Conf{ArchiveDest}/$host.$num.*";
+
+ my @tar_parts = sort map { s/^\Q$Conf{ArchiveDest}\E\/*//; $_ } glob $glob ;
+
+ if ( ! @tar_parts ) {
+ warn "ERROR: no files for $glob";
+ return;
+ }
+
+ print curr_time, " check $host $num\n";
+
+ my $sth = $dbh->prepare(qq{
+ SELECT count(*)
+ FROM files
+ JOIN shares on shares.id = shareid
+ JOIN hosts on hosts.id = shares.hostid
+ WHERE hosts.name = ? and backupnum = ?
+ });
+ $sth->execute($host, $num);
+ my ($files) = $sth->fetchrow_array;
+
+ if ( $files == 0 ) {
+ warn "EMPTY INCREMENT, cleanup ",dump( @tar_parts );
+ foreach my $path ( @tar_parts ) {
+ my $full = "$Conf{ArchiveDest}/$path";
+ warn "rm $full\n";
+ unlink $full || die "can't remove $full: $!";
+ }
+ return;
+ }