Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

src/project: put a ref to source next to gc_root #469

Closed
wants to merge 1 commit into from

Conversation

hmenke
Copy link

@hmenke hmenke commented Aug 10, 2020

Overview

Currently it is not possible to determine whether a gc_root is used or not because the path is a hash of the filename that it was created from. When the source is deleted, the gc_root will remain forever unable to be garbage collected. Once the user accumulates several projects, it is also very hard to tell which gc_root belongs to which project, because there is no bidirectional mapping.

In #16 it was suggested to add a subcommand to lorri that will automatically remove unused gc_roots, however, without a mapping from the name of the gc_root back to the location of the source this is impossible.

This commit addresses this issue in parts by creating a file with the name ref next to the gc_root which will simply contain the full path of the shell file it was originally created for. In the future this information could be used to automatically detect and garbage-collect unused gc_roots, but even without that it will enable the user to write a simple shell script which picks up each ref and checks whether the file inside exists.

Another possibility instead of using a file containing the path name would be to make ref a symlink to the shell file. When the symlink is broken, the gc_root is unused. However, that might pose a problem for users using lorri through WSL on Windows, because Windows filesystems don't support symlinks. I'm unsure whether that is a concern, but I opted for the safer option of just a plain file.

Checklist

  • Updated the documentation (code documentation, command help, ...)
  • Tested the change (unit or integration tests)
  • Amended the changelog in release.nix (see release.nix for instructions)

Currently it is not possible to determine whether a gc_root is used or
not because the path is a hash of the filename that it was created from.
When the source is deleted, the gc_root will remain forever unable to be
garbage collected.  Once the user accumulates several projects, it is
also very hard to tell which gc_root belongs to which project, because
there is no bidirectional mapping.

In target#16 it was suggested to add a subcommand to lorri that will
automatically remove unused gc_roots, however, without a mapping from
the name of the gc_root back to the location of the source this is
impossible.

This commit addresses this issue in parts by creating a file with the
name `ref' next to the gc_root which will simply contain the full path
of the shell file it was originally created for.  In the future this
information could be used to automatically detect and garbage-collect
unused gc_roots, but even without that it will enable the user to write
a simple shell script which picks up each `ref' and checks whether the
file inside exists.

Another possibility instead of using a file containing the path name
would be to make `ref' a symlink to the shell file.  When the symlink is
broken, the gc_root is unused.  However, that might pose a problem for
users using lorri through WSL on Windows, because Windows filesystems
don't support symlinks.  I'm unsure whether that is a concern, but I
opted for the safer option of just a plain file.
@hmenke
Copy link
Author

hmenke commented Aug 10, 2020

I had run the ci command locally and it all passed, so I have no idea why all the macOS tests are failing. Also the error message “This check failed” is not all too helpful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant