From patchwork Fri Apr 11 13:54:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 41582 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B8FD927BC4E; Fri, 11 Apr 2025 14:56:30 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6A8AC27BC49 for ; Fri, 11 Apr 2025 14:56:30 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u3ErZ-0002y2-Of; Fri, 11 Apr 2025 09:56:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3ErW-0002xL-Md for guix-patches@gnu.org; Fri, 11 Apr 2025 09:56:07 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u3ErW-0003r6-Cu; Fri, 11 Apr 2025 09:56:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=aGeG7j1Bmh1K9z0mhsJ66S4LuOy7cbMuuYtHZrDZ4qI=; b=bSm+KDPD9lFgD6JK4YY/wknX8JtxAS9wu5plswGIq33HQ8vC5qBHPLMy6LtyUl9CdfUbv10hZm1/KagAOnrSF/PBeXrJkHAI+xaRUTCIBoePraZVEBDjCRYj8ckUN40hR8G98Jscng770fejN85n+GQOCSrfmD9QsJDnT1ZQoX3IZRaWYqKnTmBG8LofhbP66LRQQYH/B2EEi/qfPb2S7MeD8uowXuAdZ88x6JlbB9CK7i2dUKq1bRLEwdi32ABHdd5ct8G39g31tALjCLkQNnwzXYShBvXIFcZcN7nbPi9scpaqWydegK9HkAtAx6TeviqxGoXHYHAWRrP7cvYeGw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u3ErU-0007pH-DY; Fri, 11 Apr 2025 09:56:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77680] [PATCH v2 2/4] utils: Add #:sync? parameter to =?utf-8?b?4oCYd2l0aC1hdG9taWMtZmlsZS1vdXRwdXTigJku?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 11 Apr 2025 13:56:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77680 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77680@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77680-submit@debbugs.gnu.org id=B77680.174437975329960 (code B ref 77680); Fri, 11 Apr 2025 13:56:04 +0000 Received: (at 77680) by debbugs.gnu.org; 11 Apr 2025 13:55:53 +0000 Received: from localhost ([127.0.0.1]:49929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u3ErI-0007mz-5D for submit@debbugs.gnu.org; Fri, 11 Apr 2025 09:55:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57574) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u3Er5-0007jW-Fg for 77680@debbugs.gnu.org; Fri, 11 Apr 2025 09:55:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3Er0-0003o9-6J; Fri, 11 Apr 2025 09:55:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=aGeG7j1Bmh1K9z0mhsJ66S4LuOy7cbMuuYtHZrDZ4qI=; b=p0PC9Z5oOt+d52HC19OT HJBFWnnHLPuBmDPhi11R3YKAbClbyCxjOx5Vq7vBuOWh1DnQEX2eXXOL0ZK+LdVBJQCxHFilvIU/y pHlX8JCF6/5aCv1l90U2mvP5vmi9qN4a64K1e3Aqz46bH3E0il28S2O5t0A276hx8gAerahYEKBa+ N3r3oDQhu0YiJLFNMOYz6pxs/p5uSDZF/w3iDeuxeLp5hmPIg3fCbanknRT9SdGeEtuDttODXEqH3 q6cMFRrE6ZxayLPIDDfelIB0FglFEKddFP4rJhctgRymNafoFFDxLa46k9kAUpFduwNOwvL7vqJO9 WdI4XqBInAmqcw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 11 Apr 2025 15:54:58 +0200 Message-ID: <6ad42a95eed510eecf1f9a264c24714ebe9ff2d4.1744379552.git.ludo@gnu.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/utils.scm (with-atomic-file-output): Add #:sync? and honor it. Add ‘force-output’ call. Change-Id: I2479778ae55360c0fab3389ac9249045a27b3568 --- guix/utils.scm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index c7c23d9d5b..7ae98096c2 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012-2022, 2024 Ludovic Courtès +;;; Copyright © 2012-2022, 2024-2025 Ludovic Courtès ;;; Copyright © 2013, 2014, 2015 Mark H Weaver ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2014 Ian Denhardt @@ -1057,16 +1057,22 @@ (define (call-with-temporary-directory proc) (lambda () (false-if-exception (delete-file-recursively tmp-dir)))))) -(define (with-atomic-file-output file proc) +(define* (with-atomic-file-output file proc #:key (sync? #t)) "Call PROC with an output port for the file that is going to replace FILE. Upon success, FILE is atomically replaced by what has been written to the -output port, and PROC's result is returned." +output port, and PROC's result is returned. + +When SYNC? is true, call 'fdatasync' on the temporary file before renaming it +to FILE; set it to #false for caches and temporary files to improve +performance." (let* ((template (string-append file ".XXXXXX")) (out (mkstemp! template))) (with-throw-handler #t (lambda () (let ((result (proc out))) - (fdatasync out) + (when sync? + (force-output out) + (fdatasync out)) (close-port out) (rename-file template file) result))