Guest User

Untitled

a guest
Mar 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.68 KB | None | 0 0
  1. --- redobackup  Sat Nov 19 21:51:35 2011
  2. +++ redobackup.totaltime    Sat Nov 19 21:47:47 2011
  3. @@ -271,6 +271,7 @@
  4.    $status{'last_part'} = $partlist[-1];
  5.    $status{'total_parts'} = scalar(@partlist);
  6.    $status{'current_part'} = 0;
  7. +  $status{'times'} = [];
  8.    print "\t* Partition list saved to $dest/$file.backup\n";
  9.    # Create backup by calling progress sub
  10.    print "\t* Total partitions to save: ".$status{'total_parts'}."\n";
  11. @@ -406,7 +407,8 @@
  12.          system("sync");
  13.          sleep(0.5);
  14.          system("umount ".MOUNT_POINT);
  15. -        message_box("Operation complete.");
  16. +        my $total_time = add_times($status{'times'});
  17. +        message_box("Operation completed in: $total_time");
  18.          system("notify-send -i ".APP_ICON." 'Backup saved successfully.'");
  19.          print ">>> Operation complete.\n";
  20.          return 0;
  21. @@ -417,6 +419,8 @@
  22.          print "Advancing to next partition.\n";
  23.          return TRUE;
  24.        }
  25. +    } elsif ($data =~ m/^Total Time:\s+([^,]+), Ave/) {
  26. +      push(@{$status{'times'}}, $1);
  27.      } else {
  28.        if (length($data)>0) {
  29.          print "$data\n";
  30. @@ -667,6 +671,7 @@
  31.    $status{'last_part'} = $partlist[-1];
  32.    $status{'total_parts'} = scalar(@partlist);
  33.    $status{'current_part'} = 0;
  34. +  $status{'times'} = [];
  35.    Glib::Timeout->add(50, \&update_restore_progress);
  36.    refresh_window();
  37.  }
  38. @@ -799,7 +804,8 @@
  39.          system("sync");
  40.          sleep(0.5);
  41.          system("umount ".MOUNT_POINT);
  42. -        message_box("Operation complete.");
  43. +        my $total_time = add_times($status{'times'});
  44. +        message_box("Operation completed in: $total_time");
  45.          system("notify-send -i ".APP_ICON." 'Backup restored successfully.'");
  46.          print ">>> Operation complete.\n";
  47.          return 0;
  48. @@ -810,6 +816,8 @@
  49.          print "Advancing to next partition.\n";
  50.          return TRUE;
  51.        }
  52. +    } elsif ($data =~ m/^Total Time:\s+([^,]+), Ave/) {
  53. +      push(@{$status{'times'}}, $1);
  54.      } else {
  55.        if (length($data)>0) {
  56.          print "$data\n";
  57. @@ -1601,3 +1609,31 @@
  58.    $string =~ s/\s+$//;
  59.    return $string;
  60.  }
  61. +
  62. +sub add_times {
  63. +  my $times_ref = shift;
  64. +  my($hr, $min, $sec) = (0, 0, 0);
  65. +  # add the times (durations)
  66. +  foreach my $time (@{$times_ref})
  67. +  {
  68. +    $time =~ m/^(\d+):(\d+):(\d+)$/;
  69. +    $hr += $1; $min += $2; $sec += $3;
  70. +  }
  71. +  # adjust for overflows
  72. +  while ($sec >= 60)
  73. +  {
  74. +    $sec -= 60;
  75. +    $min += 1;
  76. +  }
  77. +  while ($min >= 60)
  78. +  {
  79. +    $min -= 60;
  80. +    $hr += 1;
  81. +  }
  82. +  # zero-padding if necessary
  83. +  if ($sec < 10) { $sec = "0$sec"; }
  84. +  if ($min < 10) { $min = "0$min"; }
  85. +  if ($hr < 10) { $hr = "0$hr"; }
  86. +  return "$hr:$min:$sec";
  87. +}
  88. +
Add Comment
Please, Sign In to add comment