/[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 147 by iklaric, Fri Oct 7 12:03:56 2005 UTC revision 258 by dpavlin, Mon Dec 12 20:59:57 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                  # create new archive                  # and now a little magic to check multi-volume increments
53                  my $sth = $dbh->prepare(q{                  my $parts = 1;
54                                  INSERT INTO archive (                  if ($#selected_backup_ids == 0) {
55                                          id,                          ($parts) = $dbh->selectrow_array("select parts from backups where id = ?", undef, $selected_backup_ids[0]);
56                                          dvd_nr,                  }
                                         note,  
                                         username,  
                                         date  
                                 ) VALUES (  
                                         nextVal('archive_id_seq'),  
                                         nextVal('dvd_nr'),  
                                         ?,  
                                         ?,  
                                         NOW()  
                                 )  
                 });  
   
                 # FIXME insert user here  
                 $sth->execute($In{'note'}, 'dummy_user');  
57    
58                  if ($total_size > $Conf{MaxArchiveSize}) {                  if ($total_size > ($Conf{MaxArchiveSize} * $parts)) {
59                          $cont .= eval( q{ ${h2(Error)}});                          $cont .= eval( q{ ${h2(Error)}});
60                          $cont .= "Selected backups exceed max archive size.";                          $cont .= "Selected backups size $total_size Kb exceed max archive size $Conf{MaxArchiveSize} Kb.";
61                    } elsif ($total_size == 0) {
62                            $cont .= eval( q{ ${h2(Error)}});
63                            $cont .= "No backups selected.";
64                  } else {                  } else {
65    
66                            # create new archive
67                            my $sth = $dbh->prepare(q{
68                                                            INSERT INTO archive (
69                                                                    id,
70                                                                    dvd_nr,
71                                                                    note,
72                                                                    username,
73                                                                    date,
74                                                                    total_size
75                                                            ) VALUES (
76                                                                    nextVal('archive_id_seq'),
77                                                                    nextVal('dvd_nr'),
78                                                                    ?,
79                                                                    ?,
80                                                                    NOW(),
81                                                                    ?
82                                                            )
83                                                    });
84    
85                            $sth->execute($In{'note'}, $User, $total_size);
86    
87                          foreach my $backup_id (@selected_backup_ids) {                          foreach my $backup_id (@selected_backup_ids) {
88    
89                                  # link backups with archive                                  # link backups with archive
90                                  my $sth = $dbh->prepare(q{                                  my $sth = $dbh->prepare(q{
91                                          INSERT INTO archive_backup (                                          INSERT INTO archive_backup (
92                                                  archive_id, backup_id, status                                                  archive_id, backup_id
93                                          ) VALUES (                                          ) VALUES (
94                                                  (SELECT last_value FROM archive_id_seq), ?, ?                                                  (SELECT last_value FROM archive_id_seq), ?
95                                          )                                          )
96                                  });                                  });
97    
98                                  $sth->execute($backup_id, 'ok');                                  $sth->execute($backup_id);
99    
100                                  $dbh->commit();                                  $dbh->commit();
101    
                                 $cont .= qq{  
                                         Archived following backups:  
                                 } . join(",", @selected_backup_ids) . qq{  
                                         <br/>with following message:  
                                         <div style="border: 1px solid #e0e0e0">  
                                 } . $In{'note'} . qq{  
                                         </div>  
                                 };  
102                          }                          }
103    
104                            my ($dvd_nr) = $dbh->selectrow_array(qq{
105                                    select last_value from dvd_nr
106                            });
107    
108                            $dvd_nr ||= 'error';
109    
110                          $dbh->commit();                          $dbh->commit();
111    
112                            $cont .= q{
113                                    Archived following backups:
114                            } . join(", ", @selected_backup_ids) . q{
115                                    <br/>with total size of
116                            <b>} . sprintf("%1.2f Mb", $total_size / 1024 / 1024) . q{</b>
117                                    to media <b>} . $dvd_nr . q{</b>
118                                    with following message:
119                                    <div style="background-color: #e0e0e0; display: inline; padding: 2px;">
120                            } . $In{'note'} . q{
121                                    </div>
122                            };
123                  }                  }
124          }          }
125    

Legend:
Removed from v.147  
changed lines
  Added in v.258

  ViewVC Help
Powered by ViewVC 1.1.26