Skip to content

Conversation

@scootermon
Copy link
Contributor

This is based on top of #117, but I'm happy to rebase it.

@qkaiser qkaiser self-assigned this Sep 1, 2025


def find_dir(inodes: Mapping[int, _Inode], inum: int, names: list[str], idx: int) -> int | None:
def find_dir(inodes: Mapping[int, _Inode], inum: int, names: Sequence[str], idx: int) -> int | None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was Sequence used instead of list? I know Sequence is more generic, but list was already there, and I do not see the reason to pull in Sequence just to be more generic in a script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a change I forgot to revert. At one point I was passing down a tuple (specifically Path.parts) into this function. This required the change to Sequence to allow for tuples.
Since that's no longer necessary, I will revert this change.

if len(names) == 0:
return 1
for dent in inodes[inum]['dent']:
for dent in inodes[inum].get('dent', []):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This made me think: what was broken here, and how is it a fix?
I think the reason it was changed was, that names is a sequence of path parts, where one of them could point to a file (instead of a directory), which has no dent.
However I think, that a more direct solution would be to check for the type of inode earlier, and return None if it is not a directory.
Looking at inode type also lets us optionally resolve and follow parts if they are pointing to symlinks.

Copy link
Contributor Author

@scootermon scootermon Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _Inode type is marked as total=False so my IDE keeps complaining that 'dent' might be missing from the dictionary. To my knowledge there's nothing wrong with the current implementation, it's just a limitation of the type checking.

I guess a better fix would be to have multiple Inode types with different "required" keys, but for now I will revert the change in this PR.

@scootermon scootermon force-pushed the feat/list-recursive branch 2 times, most recently from e1e32df to b6ad0e6 Compare September 15, 2025 16:06
The default output of ubireader_list_files remains the same, but when you add '--recursive' it will recursively list all the inodes under the listpath.
It then also displays the absolute path to the files instead of just the name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants