mirror of
https://gitlab.com/khumba/nvd.git
synced 2024-11-14 00:49:26 +01:00
Make 'nvd history' ignore broken profile symlinks (fixes #20).
This commit is contained in:
parent
734da23492
commit
6118dc1168
2 changed files with 10 additions and 1 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
## 0.2.5 (unreleased)
|
## 0.2.5 (unreleased)
|
||||||
|
|
||||||
|
- Fixed `nvd history` to ignore broken profile symlinks in case they were
|
||||||
|
forcably removed somehow (issue #20).
|
||||||
|
|
||||||
- Improve the error message when calling `nvd list`, and `/run/current-system`
|
- Improve the error message when calling `nvd list`, and `/run/current-system`
|
||||||
doesn't exist (issue #21).
|
doesn't exist (issue #21).
|
||||||
|
|
||||||
|
|
8
src/nvd
8
src/nvd
|
@ -915,7 +915,13 @@ def is_link_to_profile(path: Path, profile_name: str) -> bool:
|
||||||
|
|
||||||
def make_profile_generation_list(profile_link: Path, minimum_version: int) -> List[ProfileVersion]:
|
def make_profile_generation_list(profile_link: Path, minimum_version: int) -> List[ProfileVersion]:
|
||||||
profile_name = PROFILE_LINK_REGEX.match(str(profile_link)).group("profile")
|
profile_name = PROFILE_LINK_REGEX.match(str(profile_link)).group("profile")
|
||||||
all_profile_links = [l for l in profile_link.parent.iterdir() if is_link_to_profile(l, profile_name)]
|
# Use exists() to filter out broken symlinks, which has been reported to happen
|
||||||
|
# either with `home-manager expire-generations` or `nix profile wipe-history`
|
||||||
|
# (on Darwin with the DetSys installer in case that's relevant, see issue #20).
|
||||||
|
all_profile_links = [
|
||||||
|
l for l in profile_link.parent.iterdir()
|
||||||
|
if is_link_to_profile(l, profile_name) and l.exists()
|
||||||
|
]
|
||||||
all_profile_versions = [ProfileVersion(l) for l in all_profile_links]
|
all_profile_versions = [ProfileVersion(l) for l in all_profile_links]
|
||||||
all_profile_versions.sort()
|
all_profile_versions.sort()
|
||||||
profile_versions = [pv for pv in all_profile_versions if pv.version() >= minimum_version]
|
profile_versions = [pv for pv in all_profile_versions if pv.version() >= minimum_version]
|
||||||
|
|
Loading…
Reference in a new issue