Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- redobackup Sat Nov 19 21:51:35 2011
- +++ redobackup.totaltime Sat Nov 19 21:47:47 2011
- @@ -271,6 +271,7 @@
- $status{'last_part'} = $partlist[-1];
- $status{'total_parts'} = scalar(@partlist);
- $status{'current_part'} = 0;
- + $status{'times'} = [];
- print "\t* Partition list saved to $dest/$file.backup\n";
- # Create backup by calling progress sub
- print "\t* Total partitions to save: ".$status{'total_parts'}."\n";
- @@ -406,7 +407,8 @@
- system("sync");
- sleep(0.5);
- system("umount ".MOUNT_POINT);
- - message_box("Operation complete.");
- + my $total_time = add_times($status{'times'});
- + message_box("Operation completed in: $total_time");
- system("notify-send -i ".APP_ICON." 'Backup saved successfully.'");
- print ">>> Operation complete.\n";
- return 0;
- @@ -417,6 +419,8 @@
- print "Advancing to next partition.\n";
- return TRUE;
- }
- + } elsif ($data =~ m/^Total Time:\s+([^,]+), Ave/) {
- + push(@{$status{'times'}}, $1);
- } else {
- if (length($data)>0) {
- print "$data\n";
- @@ -667,6 +671,7 @@
- $status{'last_part'} = $partlist[-1];
- $status{'total_parts'} = scalar(@partlist);
- $status{'current_part'} = 0;
- + $status{'times'} = [];
- Glib::Timeout->add(50, \&update_restore_progress);
- refresh_window();
- }
- @@ -799,7 +804,8 @@
- system("sync");
- sleep(0.5);
- system("umount ".MOUNT_POINT);
- - message_box("Operation complete.");
- + my $total_time = add_times($status{'times'});
- + message_box("Operation completed in: $total_time");
- system("notify-send -i ".APP_ICON." 'Backup restored successfully.'");
- print ">>> Operation complete.\n";
- return 0;
- @@ -810,6 +816,8 @@
- print "Advancing to next partition.\n";
- return TRUE;
- }
- + } elsif ($data =~ m/^Total Time:\s+([^,]+), Ave/) {
- + push(@{$status{'times'}}, $1);
- } else {
- if (length($data)>0) {
- print "$data\n";
- @@ -1601,3 +1609,31 @@
- $string =~ s/\s+$//;
- return $string;
- }
- +
- +sub add_times {
- + my $times_ref = shift;
- + my($hr, $min, $sec) = (0, 0, 0);
- + # add the times (durations)
- + foreach my $time (@{$times_ref})
- + {
- + $time =~ m/^(\d+):(\d+):(\d+)$/;
- + $hr += $1; $min += $2; $sec += $3;
- + }
- + # adjust for overflows
- + while ($sec >= 60)
- + {
- + $sec -= 60;
- + $min += 1;
- + }
- + while ($min >= 60)
- + {
- + $min -= 60;
- + $hr += 1;
- + }
- + # zero-padding if necessary
- + if ($sec < 10) { $sec = "0$sec"; }
- + if ($min < 10) { $min = "0$min"; }
- + if ($hr < 10) { $hr = "0$hr"; }
- + return "$hr:$min:$sec";
- +}
- +
Add Comment
Please, Sign In to add comment