From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sLF7MR1vp2BmMgEAgWs5BA (envelope-from ) for ; Fri, 21 May 2021 10:28:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id UFUoLR1vp2DVLgAAbx9fmQ (envelope-from ) for ; Fri, 21 May 2021 08:28:13 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 464CC1678E for ; Fri, 21 May 2021 10:28:13 +0200 (CEST) Received: from localhost ([::1]:57800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lk0Vw-0005yq-1O for larch@yhetil.org; Fri, 21 May 2021 04:28:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk0Vn-0005wr-Gu for guix-patches@gnu.org; Fri, 21 May 2021 04:28:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lk0Vn-0005Oo-9Q for guix-patches@gnu.org; Fri, 21 May 2021 04:28:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lk0Vn-00062V-6f for guix-patches@gnu.org; Fri, 21 May 2021 04:28:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48558] [PATCH 3/4] progress: Add a download-size argument to progress-report-port. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 21 May 2021 08:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48558 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48558@debbugs.gnu.org Cc: Mathieu Othacehe X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162158565223150 (code B ref -1); Fri, 21 May 2021 08:28:03 +0000 Received: (at submit) by debbugs.gnu.org; 21 May 2021 08:27:32 +0000 Received: from localhost ([127.0.0.1]:35740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lk0VI-00061J-1t for submit@debbugs.gnu.org; Fri, 21 May 2021 04:27:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:44362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lk0VF-000610-VJ for submit@debbugs.gnu.org; Fri, 21 May 2021 04:27:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk0VF-0005JB-Ku for guix-patches@gnu.org; Fri, 21 May 2021 04:27:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36138) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lk0VE-00053e-Am for guix-patches@gnu.org; Fri, 21 May 2021 04:27:29 -0400 Received: from [2a01:e0a:19b:d9a0:f2f7:a404:c3d3:f8b4] (port=37126 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lk0VB-0003nM-PO; Fri, 21 May 2021 04:27:26 -0400 From: Mathieu Othacehe Date: Fri, 21 May 2021 10:27:12 +0200 Message-Id: <20210521082713.20169-3-othacehe@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210521082713.20169-1-othacehe@gnu.org> References: <20210521082713.20169-1-othacehe@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621585693; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=kg6H3WicDagqAP0cvCn93Y4Xne47ZXmyiztPgsGqia4=; b=JkhbjkmB2SA23elvcj++R+WC9X4U3+lElkxr7cr69JD1daY/jjequ0XA8iQPSPttosPaGy f+MquiMuB4vxVIe3wIRftH1jb/U+ci3+j5yV0Ihji0BTz2n6NfwdT8j4wM6p47cyYxD+1a s8S3rpmqf29ODx+f7u89npegt/d6vRzfYuVblG+IiF7UxsFjaHu1jSymFPIvyouHQMNMmk x51jIQCewIw+or6J7clUNdb5zWng3iSY5o2O1ZvsJSqUb60CN1Vakn6NAOhr2VuZvRsASD 06iho3S61UVwqnxpxQWxWxJ9utWosY1AdwJav1bDjhoiXw+S3QRMQDdtJ2YSSA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621585693; a=rsa-sha256; cv=none; b=nbzvyaWo6YqNIM/edEjJVNyv14gQfHPr1WAJxJtOPM56LkIoYIGijqN7hld9DAGVb8YwG/ Num1pu5FkoblzMvRYu39TZBNUmvgF5zCgdes0iIUEu1cX434c15iwyRKxli/L2qZESrwWM XCCw2RjnbP68AtDXXnYu6cCG1/0J7sVrHkMpq8z3lyeyjhTQLb+zjEIg1GpFfu19PQ+J0J YHvPTeAJxO1hswzYBZpQ3XU63SR4f9YVAoVxRAz2pSGY22Ol1cZwoKpCe0+zmy6YTeLk1E l5kg/JU5xoFCXRSFd9AmtqfkfrQitv24thMCpQL1KUlIHDRSfHwpdSRGirZAFg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 2.06 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 464CC1678E X-Spam-Score: 2.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: 1VTgO78dwF8U * guix/progress.scm (progress-report-port): Add a download-size argument. --- guix/progress.scm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/guix/progress.scm b/guix/progress.scm index 334bd40547..0cbc804ec1 100644 --- a/guix/progress.scm +++ b/guix/progress.scm @@ -347,15 +347,25 @@ should be a object." (report total) (loop total (get-bytevector-n! in buffer 0 buffer-size)))))))) -(define* (progress-report-port reporter port #:key (close? #t)) +(define* (progress-report-port reporter port + #:key + (close? #t) + download-size) "Return a port that continuously reports the bytes read from PORT using REPORTER, which should be a object. When CLOSE? is true, -PORT is closed when the returned port is closed." +PORT is closed when the returned port is closed. + +When DOWNLOAD-SIZE is passed, do not read more than DOWNLOAD-SIZE bytes from +PORT. This is important to avoid blocking when the remote side won't close +the underlying connection." (match reporter (($ start report stop) (let* ((total 0) (read! (lambda (bv start count) - (let ((n (match (get-bytevector-n! port bv start count) + (let* ((count (if download-size + (min count (- download-size total)) + count)) + (n (match (get-bytevector-n! port bv start count) ((? eof-object?) 0) (x x)))) (set! total (+ total n)) -- 2.31.1