From 6b7d011680c77642f24396be0eb0015c20413d1a Mon Sep 17 00:00:00 2001 From: Caleb Ristvedt Date: Sat, 8 Aug 2020 08:31:38 -0500 Subject: [PATCH 4/6] nar: ensure finalization target is a temp root during registration. Note that this is currently unnecessary, as finalize-store-file is only used from the offload hook, and the daemon process that spawned the offload hook will have already registered the derivation outputs as temp roots prior to attempting to offload (see haveDerivation() in nix/libstore/build.cc). But it's necessary to ensure that the register-items invocation works properly when finalize-store-file is used in other contexts. * guix/nar.scm (finalize-store-file): make target a temp root during extent of register-items invocation. --- guix/nar.scm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/guix/nar.scm b/guix/nar.scm index a2aacf585c..ffb487e185 100644 --- a/guix/nar.scm +++ b/guix/nar.scm @@ -111,13 +111,24 @@ held." (when (file-exists? target) (delete-file-recursively target)) - ;; Install the new TARGET. - (rename-file source target) + ;; Register TARGET as a temp root. Note that this may not always be + ;; necessary, but adding a temp root multiple times doesn't change + ;; anything (except taking a little more space in the temproots + ;; file). Note that currently this will only ensure that TARGET + ;; doesn't get deleted between now and when registration finishes; + ;; it may well be deleted by the time this procedure returns. - ;; Register TARGET. As a side effect, it resets the timestamps of all - ;; its files, recursively, and runs a deduplication pass. - (register-items db - (list (store-info target deriver references)))) + ;; TODO: don't use an RPC for this, add it to *this process's* temp + ;; roots file. + (with-store store + (add-temp-root store target) + ;; Install the new TARGET. + (rename-file source target) + + ;; Register TARGET. As a side effect, it resets the timestamps of + ;; all its files, recursively, and runs a deduplication pass. + (register-items db + (list (store-info target deriver references))))) (when lock? (delete-file (string-append target ".lock")) -- 2.28.0