summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-10-30 21:38:57 +0000
committerOlivier Blin <oblin@mandriva.com>2008-10-30 21:38:57 +0000
commit128ea67c45407625d533bf76ff5f93c4adb56443 (patch)
tree8d0984e2044ce40e7d8500e43c74f645ecdce920
parent1ce24fb58672906515ed53ff4dd23e7b806373ed (diff)
downloaddraklive-128ea67c45407625d533bf76ff5f93c4adb56443.tar
draklive-128ea67c45407625d533bf76ff5f93c4adb56443.tar.gz
draklive-128ea67c45407625d533bf76ff5f93c4adb56443.tar.bz2
draklive-128ea67c45407625d533bf76ff5f93c4adb56443.tar.xz
draklive-128ea67c45407625d533bf76ff5f93c4adb56443.zip
factorize rsync progress update code
-rwxr-xr-xdraklive50
1 files changed, 20 insertions, 30 deletions
diff --git a/draklive b/draklive
index a596b4f..ae2ae9e 100755
--- a/draklive
+++ b/draklive
@@ -796,24 +796,12 @@ sub record_usb_master {
do {
my $loopbacks_source = $live->get_builddir . $live->{prefix}{build}{loopbacks} . '/';
my $total = directory_usage($loopbacks_source);
- my $all_files = 0;
- my $current_file = 0;
my $list_file = tmpnam();
output_p($list_file, map { ".$_\n" } list_selected_loopbacks($live));
local $/ = "\r";
- my $r = run_foreach(
- $live->{update_progress} ? sub {
- if (/^\s*(\d+)\s+\d+%\s+/) {
- $current_file = $1;
- $live->{update_progress}->(undef, $all_files + $current_file, $total);
- }
- if (/(?:^|\n)\S+/) {
- $all_files += $current_file;
- $current_file = 0;
- }
- } : sub { print },
- 'rsync', '-vdP', '--inplace', '--files-from=' . $list_file,
- $loopbacks_source, $live->{mnt} . $media_loopbacks,
+ my $r = run_foreach(update_progress_rsync($live, $total),
+ 'rsync', '-vdP', '--inplace', '--files-from=' . $list_file,
+ $loopbacks_source, $live->{mnt} . $media_loopbacks,
);
unlink $list_file;
if (!$r) {
@@ -856,22 +844,8 @@ sub record_harddisk_master {
do {
my $source = $live->get_system_root;
my $total = directory_usage($source);
- my $all_files = 0;
- my $current_file = 0;
local $/ = "\r";
- my $r = run_foreach(
- $live->{update_progress} ? sub {
- if (/^\s*(\d+)\s+\d+%\s+/) {
- $current_file = $1;
- $live->{update_progress}->(undef, $all_files + $current_file, $total);
- }
- if (/(?:^|\n)\S+/) {
- $all_files += $current_file;
- $current_file = 0;
- }
- } : sub { print },
- 'rsync', '-avP', $source . '/', $live->{mnt},
- );
+ my $r = run_foreach(update_progress_rsync($live, $total), 'rsync', '-avP', $source . '/', $live->{mnt});
if (!$r) {
run_('umount', $live->{mnt});
maybe_umount_device($device);
@@ -1044,6 +1018,22 @@ sub create_replicator {
}
}
+sub update_progress_rsync {
+ my ($live, $total) = @_;
+ my $all_files = 0;
+ my $current_file = 0;
+ $live->{update_progress} ? sub {
+ if (/^\s*(\d+)\s+\d+%\s+/) {
+ $current_file = $1;
+ $live->{update_progress}->(undef, $all_files + $current_file, $total);
+ }
+ if (/(?:^|\n)\S+/) {
+ $all_files += $current_file;
+ $current_file = 0;
+ }
+ } : sub { print };
+}
+
sub copy_wizard {
my ($live) = @_;