Subject: Re: [bug#51427] [PATCH] nix: libstore: Do not remove unused links when deleting specific items.

From: zimoun <[email-masked]>
Date: Wed, 17 Nov 2021 12:49:09 +0100

Hi Ludo,

On Wed, 17 Nov 2021 at 11:02, Ludovic Courtès <[email-masked]> wrote:
> zimoun <[email-masked]> skribis:
>
>> I have not checked the code, maybe I should start by that. ;-) Is it not
>> possible to simply skip the deleting phase when the option ’-D’ is used?
>
> No; like I wrote, it would have the effect of not deleting anything:

After giving a look at the code, yeah it is not so simple. :-)

>   https://issues.guix.gnu.org/51427#1
>
> Needs more thought…

The logic is complicated, thus adding this guard…

--8<---------------cut here---------------start------------->8---
    if (options.maxFreed > 0) {      
      /* Clean up the links directory. */
      if (options.action == GCOptions::gcDeleteDead || options.action == GCOptions::gcDeleteSpecific) {
        printMsg(lvlError, format("deleting unused links..."));
        removeUnusedLinks(state);
      }      
    }
--8<---------------cut here---------------end--------------->8---

…is probably dumb.  From my understanding, it should bypass the phase
’removeUnusedLinks’ when using “guix gc -D”.  Well, I have not tested
it.

Cheers,
simon