/[BackupPC]/trunk/bin/BackupPC_updatedb
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_updatedb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 324 by dpavlin, Sun Jan 29 18:08:52 2006 UTC revision 325 by dpavlin, Tue Jan 31 16:29:30 2006 UTC
# Line 126  sub hest_update { Line 126  sub hest_update {
126          my $offset = 0;          my $offset = 0;
127          my $added = 0;          my $added = 0;
128    
         print " opening index $index_node_url";  
129          if ($index_node_url) {          if ($index_node_url) {
130                    print " opening index $index_node_url";
131                  $hest_node ||= Search::Estraier::Node->new(                  $hest_node ||= Search::Estraier::Node->new(
132                          url => $index_node_url,                          url => $index_node_url,
133                          user => 'admin',                          user => 'admin',
# Line 135  sub hest_update { Line 135  sub hest_update {
135                          croak_on_error => 1,                          croak_on_error => 1,
136                  );                  );
137                  print " via node URL";                  print " via node URL";
         } else {  
                 die "don't know how to use Hyper Estraier Index $index_node_url";  
138          }          }
139    
140          my $results = 0;          my $results = 0;
# Line 199  sub hest_update { Line 197  sub hest_update {
197                  while (my $row = $sth->fetchrow_hashref()) {                  while (my $row = $sth->fetchrow_hashref()) {
198    
199                          my $uri = $row->{hname} . ':' . $row->{sname} . '#' . $row->{backupnum} . ' ' . $row->{filepath};                          my $uri = $row->{hname} . ':' . $row->{sname} . '#' . $row->{backupnum} . ' ' . $row->{filepath};
200                          unless ($skip_check) {                          unless ($skip_check && $hest_node) {
201                                  my $id = $hest_node->uri_to_id($uri);                                  my $id = $hest_node->uri_to_id($uri);
202                                  next if ($id && $id == -1);                                  next if ($id && $id == -1);
203                          }                          }
# Line 304  if ($opt{c}) { Line 302  if ($opt{c}) {
302                          size    bigint          not null,                          size    bigint          not null,
303                          inc_size bigint         not null default -1,                          inc_size bigint         not null default -1,
304                          inc_deleted boolean     default false,                          inc_deleted boolean     default false,
305                          parts   integer         not null default 1,                          parts   integer         not null default 0,
306                          PRIMARY KEY(id)                          PRIMARY KEY(id)
307                  );                              );            
308    
# Line 384  if ($opt{c}) { Line 382  if ($opt{c}) {
382                  $dbh->do( qq{ CREATE SEQUENCE $seq } );                  $dbh->do( qq{ CREATE SEQUENCE $seq } );
383          }          }
384    
385            print " creating triggers ";
386            $dbh->do( qq{
387                    create or replace function backup_parts_check() returns trigger as '
388                    declare
389                            b_parts integer;
390                            b_counted integer;
391                            b_id    integer;
392                    begin
393                            if (TG_OP=''UPDATE'') then
394                                    b_id := old.id;
395                                    b_parts := old.parts;
396                            elsif (TG_OP = ''INSERT'') then
397                                    b_id := new.id;
398                                    b_parts := new.parts;
399                            end if;
400                            b_counted := (select count(*) from backup_parts where backup_id = b_id);
401                            if ( b_parts != b_counted ) then
402                                    raise exception ''Update of backup % aborted, requested % parts and there are really % parts'', b_id, b_parts, b_counted;
403                            end if;
404                            return null;
405                    end;
406                    ' language plpgsql;
407    
408                    create trigger do_backup_parts_check
409                            after insert or update or delete on backups
410                            for each row execute procedure backup_parts_check();
411            });
412    
413          print "...\n";          print "...\n";
414    

Legend:
Removed from v.324  
changed lines
  Added in v.325

  ViewVC Help
Powered by ViewVC 1.1.26