From 1c03ee6c6dcfd52bc84bb4cc3a7b0ed1a9276ed2 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Thu, 17 Dec 2009 11:07:25 +0000 Subject: add a callback to file creation, so that we get progress meter for huge files in packages. Should affect emacs, chrome and the likes. --- usr.sbin/pkg_add/OpenBSD/Add.pm | 8 ++++++-- usr.sbin/pkg_add/OpenBSD/Ustar.pm | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD') diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index acccea3603c..0e02e81fdb2 100644 --- a/usr.sbin/pkg_add/OpenBSD/Add.pm +++ b/usr.sbin/pkg_add/OpenBSD/Add.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Add.pm,v 1.98 2009/12/17 08:21:09 espie Exp $ +# $OpenBSD: Add.pm,v 1.99 2009/12/17 11:07:24 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -171,6 +171,10 @@ sub prepare_for_addition sub install_and_progress { my ($self, $state, $donesize, $totsize) = @_; + $state->{callback} = sub { + my $done = shift; + $state->progress->show($$donesize + $done, $totsize); + }; unless ($state->{do_faked} && $state->{end_faked}) { $self->install($state); } @@ -406,7 +410,7 @@ sub install $state->{archive}->skip; return; } else { - $file->create; + $file->create($state->{callback}); $self->may_check_digest($file, $state); } diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index 385b90f804e..ff7ba96435c 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Ustar.pm,v 1.52 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.53 2009/12/17 11:07:24 espie Exp $ # # Copyright (c) 2002-2007 Marc Espie # @@ -629,7 +629,7 @@ sub new sub create { - my $self = shift; + my ($self, $callback) = @_; $self->make_basedir($self->name); my $buffer; my $out = OpenBSD::CompactWriter->new($self->{destdir}.$self->name); @@ -654,6 +654,9 @@ sub create } $toread -= $actual; + if ($toread > 0 && defined $callback) { + &$callback($self->{size} - $toread); + } } $out->close or die "Error closing $self->{destdir}", $self->name, ": $!"; -- cgit v1.2.3