Skip to content

nar-accessor: use tree, fixes readDirectory missing children #1386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 24, 2017

Conversation

bennofs
Copy link
Contributor

@bennofs bennofs commented May 15, 2017

Previously, if a directory foo existed and a file foo- (where - is any character that is sorted before /), then readDirectory would return an empty list.

To fix this, we now use a tree where we can just access the children of the node, and do not need to rely on sorting behavior to list the contents of a directory.

Here's the diff for https://cache.nixos.org/nar/0iganlam4ism8v20n41rsw3x1mjwh9hmpgikj6iaikwis20n0qmw.nar (path /nix/store/cpprsynaygxhx5xw30m0g873yy3v5mpm-glibc-2.25-dev):

--- before	2017-05-15 10:21:00.850022680 +0200
+++ after	2017-05-15 10:21:45.346690356 +0200
@@ -133,6 +133,15 @@
 ./include/bits/timerfd.h
 ./include/bits/timex.h
 ./include/bits/types
+./include/bits/types/clock_t.h
+./include/bits/types/clockid_t.h
+./include/bits/types/struct_itimerspec.h
+./include/bits/types/struct_osockaddr.h
+./include/bits/types/struct_timespec.h
+./include/bits/types/struct_timeval.h
+./include/bits/types/struct_tm.h
+./include/bits/types/time_t.h
+./include/bits/types/timer_t.h
 ./include/bits/types.h
 ./include/bits/typesizes.h
 ./include/bits/uintn-identity.h
@@ -179,6 +188,11 @@
 ./include/getopt.h
 ./include/glob.h
 ./include/gnu
+./include/gnu/lib-names-32.h
+./include/gnu/lib-names.h
+./include/gnu/libc-version.h
+./include/gnu/stubs-32.h
+./include/gnu/stubs.h
 ./include/gnu-versions.h
 ./include/grp.h
 ./include/gshadow.h

Previously, if a directory `foo` existed and a file `foo-` (where `-` is any character that is sorted before `/`), then  `readDirectory` would return an empty list.

To fix this, we now use a tree where we can just access the children of the node, and do not need to rely on sorting behavior to list the contents of a directory.
@domenkozar
Copy link
Member

@bennofs nice, can you add a simple test case as well?

@bennofs
Copy link
Contributor Author

bennofs commented May 15, 2017

@domenkozar tests added

This avoids a possible stack overflow if directories are very deeply nested.
@bennofs bennofs force-pushed the nar-accessor-tree branch from 6a50329 to 5ee06e6 Compare May 15, 2017 17:34
@bennofs bennofs force-pushed the nar-accessor-tree branch from 0f1ffc7 to a1f428b Compare May 15, 2017 17:42
@bennofs
Copy link
Contributor Author

bennofs commented May 23, 2017

@edolstra any update on this? (sorry if you don't like pings, just tell me and I won't ping you again. or should I ping someone else?)

@edolstra
Copy link
Member

Thanks, merged!

@edolstra edolstra merged commit a1f428b into NixOS:master May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants