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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 eachref
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
release.nix
(seerelease.nix
for instructions)