/[BackupPC]/trunk/lib/BackupPC/CGI/BurnMedia.pm
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/lib/BackupPC/CGI/BurnMedia.pm

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

revision 150 by dpavlin, Mon Oct 10 10:25:37 2005 UTC revision 217 by dpavlin, Sun Oct 16 17:41:52 2005 UTC
# Line 31  sub action() { Line 31  sub action() {
31  EOF  EOF
32                                
33                  $cont .= "Backups that have not been archived:<br>";                  $cont .= "Backups that have not been archived:<br>";
34                  $cont .= BackupPC::SearchLib::displayBackupsGrid();                  $cont .= BackupPC::SearchLib::displayBackupsGrid( \%In );
35                            
36          } else {          } else {
37    
38                  my @selected_backup_ids;                  my @selected_backup_ids;
39    
40                  my $total_size = 0;                  my $total_size = 0;
41                                    my $selected = 0;
42    
43                  foreach my $key(keys(%In)) {                  foreach my $key(keys(%In)) {
44                          if ($key =~ m/^fcb([0-9]+)_([0-9]+)_([0-9]+)$/gi) {                          if ($key =~ m/^fcb([0-9]+)_([0-9]+)_([0-9]+)$/gi) {
45                                  my ($host_id, $backup_num, $backup_id) = ($1,$2,$3);                                  my ($host_id, $backup_num, $backup_id) = ($1,$2,$3);
46                                  push @selected_backup_ids, $backup_id;                                  push @selected_backup_ids, $backup_id;
47                                  $total_size += BackupPC::SearchLib::getGzipSize($host_id, $backup_num);                                  $total_size += BackupPC::SearchLib::getGzipSize($host_id, $backup_num);
48                                    $selected++;
49                          }                          }
50                  }                  }
51    
52                    my $total_kb = int($total_size / 1024);
53    
54                    # and now a little magic to check multi-volume increments
55                    my $parts = 1;
56                    if ($#selected_backup_ids == 0) {
57                            ($parts) = $dbh->selectrow_array("select parts from backups where id = ?", undef, $selected_backup_ids[0]);
58                    }
59    
60                  if ($total_size > $Conf{MaxArchiveSize}) {                  if ($total_kb > ($Conf{MaxArchiveSize} * $parts)) {
61                            $cont .= eval( q{ ${h2(Error)}});
62                            $cont .= "Selected backups size $total_kb Kb exceed max archive size $Conf{MaxArchiveSize} Kb.";
63                    } elsif ($total_size == 0) {
64                          $cont .= eval( q{ ${h2(Error)}});                          $cont .= eval( q{ ${h2(Error)}});
65                          $cont .= "Selected backups exceed max archive size.";                          $cont .= "No backups selected.";
66                  } else {                  } else {
67    
68                          # create new archive                          # create new archive
# Line 60  EOF Line 72  EOF
72                                                                  dvd_nr,                                                                  dvd_nr,
73                                                                  note,                                                                  note,
74                                                                  username,                                                                  username,
75                                                                  date                                                                  date,
76                                                                    total_size
77                                                          ) VALUES (                                                          ) VALUES (
78                                                                  nextVal('archive_id_seq'),                                                                  nextVal('archive_id_seq'),
79                                                                  nextVal('dvd_nr'),                                                                  nextVal('dvd_nr'),
80                                                                  ?,                                                                  ?,
81                                                                  ?,                                                                  ?,
82                                                                  NOW()                                                                  NOW(),
83                                                                    ?
84                                                          )                                                          )
85                                                  });                                                  });
86    
87                          # FIXME insert user here                          $sth->execute($In{'note'}, $User, $total_size);
                         $sth->execute($In{'note'}, 'dummy_user');  
88    
89                          foreach my $backup_id (@selected_backup_ids) {                          foreach my $backup_id (@selected_backup_ids) {
90    
91                                  # link backups with archive                                  # link backups with archive
92                                  my $sth = $dbh->prepare(q{                                  my $sth = $dbh->prepare(q{
93                                          INSERT INTO archive_backup (                                          INSERT INTO archive_backup (
94                                                  archive_id, backup_id, status                                                  archive_id, backup_id
95                                          ) VALUES (                                          ) VALUES (
96                                                  (SELECT last_value FROM archive_id_seq), ?, ?                                                  (SELECT last_value FROM archive_id_seq), ?
97                                          )                                          )
98                                  });                                  });
99    
100                                  $sth->execute($backup_id, 'ok');                                  $sth->execute($backup_id);
101    
102                                  $dbh->commit();                                  $dbh->commit();
103    
# Line 102  EOF Line 115  EOF
115                                  Archived following backups:                                  Archived following backups:
116                          } . join(", ", @selected_backup_ids) . q{                          } . join(", ", @selected_backup_ids) . q{
117                                  <br/>with total size of                                  <br/>with total size of
118                          <b>} . sprintf("%1.2f Mb", $total_size / 1024) . q{</b>                          <b>} . sprintf("%1.2f Mb", $total_size / 1024 / 1024) . q{</b>
119                                  to media <b>} . $dvd_nr . q{</b>                                  to media <b>} . $dvd_nr . q{</b>
120                                  with following message:                                  with following message:
121                                  <div style="background-color: #e0e0e0; display: inline; padding: 2px;">                                  <div style="background-color: #e0e0e0; display: inline; padding: 2px;">

Legend:
Removed from v.150  
changed lines
  Added in v.217

  ViewVC Help
Powered by ViewVC 1.1.26