RestoreInfo.pm (BackupPC-4.3.2) | : | RestoreInfo.pm (BackupPC-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | # GNU General Public License for more details. | |||
# | # | |||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | |||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
# | # | |||
#======================================================================== | #======================================================================== | |||
# | # | |||
# Version 4.3.2, released 17 Feb 2020. | # Version 4.4.0, released 20 Jun 2020. | |||
# | # | |||
# See http://backuppc.sourceforge.net. | # See http://backuppc.sourceforge.net. | |||
# | # | |||
#======================================================================== | #======================================================================== | |||
package BackupPC::CGI::RestoreInfo; | package BackupPC::CGI::RestoreInfo; | |||
use strict; | use strict; | |||
use BackupPC::CGI::Lib qw(:all); | use BackupPC::CGI::Lib qw(:all); | |||
use Encode qw/decode_utf8/; | use Encode qw/decode_utf8/; | |||
sub action | sub action | |||
{ | { | |||
my $Privileged = CheckPermission($In{host}); | my $Privileged = CheckPermission($In{host}); | |||
my $host = $1 if ( $In{host} =~ /(.*)/ ); | my $host = $1 if ( $In{host} =~ /(.*)/ ); | |||
my $num = $In{num}; | my $num = $In{num}; | |||
my $i; | my $i; | |||
if ( !$Privileged ) { | if ( !$Privileged ) { | |||
ErrorExit($Lang->{Only_privileged_users_can_view_restore_information}); | ErrorExit($Lang->{Only_privileged_users_can_view_restore_information}); | |||
} | } | |||
# | # | |||
# Find the requested restore | # Find the requested restore | |||
# | # | |||
my @Restores = $bpc->RestoreInfoRead($host); | my @Restores = $bpc->RestoreInfoRead($host); | |||
for ( $i = 0 ; $i < @Restores ; $i++ ) { | for ( $i = 0 ; $i < @Restores ; $i++ ) { | |||
last if ( $Restores[$i]{num} == $num ); | last if ( $Restores[$i]{num} == $num ); | |||
} | } | |||
if ( $i >= @Restores ) { | if ( $i >= @Restores ) { | |||
ErrorExit(eval("qq{$Lang->{Restore_number__num_for_host__does_not_exist} }")); | ErrorExit(eval("qq{$Lang->{Restore_number__num_for_host__does_not_exist} }")); | |||
} | } | |||
%RestoreReq = (); | %RestoreReq = (); | |||
do "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" | do "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" | |||
if ( -f "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" ); | if ( -f "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" ); | |||
my $startTime = timeStamp2($Restores[$i]{startTime}); | my $startTime = timeStamp2($Restores[$i]{startTime}); | |||
my $reqTime = timeStamp2($RestoreReq{reqTime}); | my $reqTime = timeStamp2($RestoreReq{reqTime}); | |||
my $dur = $Restores[$i]{endTime} - $Restores[$i]{startTime}; | my $dur = $Restores[$i]{endTime} - $Restores[$i]{startTime}; | |||
$dur = 1 if ( $dur <= 0 ); | $dur = 1 if ( $dur <= 0 ); | |||
my $duration = sprintf("%.1f", $dur / 60); | my $duration = sprintf("%.1f", $dur / 60); | |||
my $MB = sprintf("%.1f", $Restores[$i]{size} / (1024*1024)); | my $MB = sprintf("%.1f", $Restores[$i]{size} / (1024 * 1024)); | |||
my $MBperSec = sprintf("%.2f", $Restores[$i]{size} / (1024*1024*$dur)); | my $MBperSec = sprintf("%.2f", $Restores[$i]{size} / (1024 * 1024 * $dur)); | |||
my $fileListStr = ""; | my $fileListStr = ""; | |||
foreach my $f ( @{$RestoreReq{fileList}} ) { | foreach my $f ( @{$RestoreReq{fileList}} ) { | |||
my $targetFile = $f; | my $targetFile = $f; | |||
(my $strippedShareSrc = $RestoreReq{shareSrc}) =~ s/^\///; | (my $strippedShareSrc = $RestoreReq{shareSrc}) =~ s/^\///; | |||
(my $strippedShareDest = $RestoreReq{shareDest}) =~ s/^\///; | (my $strippedShareDest = $RestoreReq{shareDest}) =~ s/^\///; | |||
substr($targetFile, 0, length($RestoreReq{pathHdrSrc})) | substr($targetFile, 0, length($RestoreReq{pathHdrSrc})) = $RestoreReq{pa | |||
= $RestoreReq{pathHdrDest}; | thHdrDest}; | |||
$targetFile =~ s{//+}{/}g; | $targetFile =~ s{//+}{/}g; | |||
$strippedShareDest = decode_utf8($strippedShareDest); | $strippedShareDest = decode_utf8($strippedShareDest); | |||
$targetFile = decode_utf8($targetFile); | $targetFile = decode_utf8($targetFile); | |||
$strippedShareSrc = decode_utf8($strippedShareSrc); | $strippedShareSrc = decode_utf8($strippedShareSrc); | |||
$f = decode_utf8($f); | $f = decode_utf8($f); | |||
$fileListStr .= <<EOF; | $fileListStr .= <<EOF; | |||
<tr><td>$RestoreReq{hostSrc}:/$strippedShareSrc$f</td><td>$RestoreReq{hostDest}: /$strippedShareDest$targetFile</td></tr> | <tr><td>$RestoreReq{hostSrc}:/$strippedShareSrc$f</td><td>$RestoreReq{hostDest}: /$strippedShareDest$targetFile</td></tr> | |||
EOF | EOF | |||
} | } | |||
$RestoreReq{shareSrc} = decode_utf8($RestoreReq{shareSrc}); | $RestoreReq{shareSrc} = decode_utf8($RestoreReq{shareSrc}); | |||
$RestoreReq{shareDest} = decode_utf8($RestoreReq{shareDest}); | $RestoreReq{shareDest} = decode_utf8($RestoreReq{shareDest}); | |||
my $content = eval("qq{$Lang->{Restore___num_details_for__host2}}"); | my $content = eval("qq{$Lang->{Restore___num_details_for__host2}}"); | |||
Header(eval("qq{$Lang->{Restore___num_details_for__host}}"),$content); | Header(eval("qq{$Lang->{Restore___num_details_for__host}}"), $content); | |||
Trailer(); | Trailer(); | |||
} | } | |||
1; | 1; | |||
End of changes. 7 change blocks. | ||||
19 lines changed or deleted | 19 lines changed or added |