elbevalidate: treat hard-linked tar members as files - #484
Closed
koalo wants to merge 1 commit into
Closed
Conversation
t-8ch
requested changes
Sep 1, 2026
| src_dir = tmp_path / 'src' | ||
| src_dir.mkdir() | ||
| src_dir.joinpath('a-original-file').write_text('Test content') | ||
| os.link(src_dir / 'a-original-file', src_dir / 'b-hardlinked-file') |
Collaborator
There was a problem hiding this comment.
Please use pathlib, ie Path.hardlink_to().
Contributor
Author
There was a problem hiding this comment.
| info = self._info() | ||
| if info.islnk(): | ||
| # For hard-links in tar files, isfile() is false | ||
| info = self.tar.getmember(info.linkname) |
Collaborator
There was a problem hiding this comment.
Why do we only need this for is_file() and not the other accessors, for example stat()?
It looks to me like we want to do this automatically in _info().
This now also has the issue, that the hardlink in a tar file can be broken, if the target does not exist.
But I think we can just wrap the KeyError from getmember() with a more descript error message.
Contributor
Author
There was a problem hiding this comment.
Good point! I moved it to _info() and also catched the KeyError:
TarPath.is_file() checked TarInfo.isfile(), which is only true for regular-file tar entries. For hard links, this is false even though we consider a hard linked file existent for every practical use. Without this fix, checking for /usr/bin/unzip in the base-rootfs.tgz fails. Signed-off-by: Florian Kauer <florian.kauer@linutronix.de>
koalo
force-pushed
the
devel/koalo/fix-hardlinks
branch
from
September 1, 2026 08:36
b9f2b08 to
74c1216
Compare
Collaborator
|
Applied with minor changes, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TarPath.is_file() checked TarInfo.isfile(), which is only true for regular-file tar entries. For hard links, this is false even though we consider a hard linked file existent for every practical use.
Without this fix, checking for /usr/bin/unzip in the base-rootfs.tgz fails.