Merge pull request #48744 from timbertson/isStorePath

lib.isStorePath: fix `false` result when given a path object
This commit is contained in:
Robert Hensing 2018-10-28 10:50:54 +01:00 committed by GitHub
commit 6b3bff4378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -502,9 +502,12 @@ rec {
=> false => false
*/ */
isStorePath = x: isStorePath = x:
isCoercibleToString x if isCoercibleToString x then
&& builtins.substring 0 1 (toString x) == "/" let str = toString x; in
&& dirOf x == builtins.storeDir; builtins.substring 0 1 str == "/"
&& dirOf str == builtins.storeDir
else
false;
/* Convert string to int /* Convert string to int
Obviously, it is a bit hacky to use fromJSON that way. Obviously, it is a bit hacky to use fromJSON that way.

View File

@ -112,7 +112,7 @@ runTests {
storePathAppendix = isStorePath storePathAppendix = isStorePath
"${goodPath}/bin/python"; "${goodPath}/bin/python";
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath))); nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
asPath = isStorePath goodPath; asPath = isStorePath (/. + goodPath);
otherPath = isStorePath "/something/else"; otherPath = isStorePath "/something/else";
otherVals = { otherVals = {
attrset = isStorePath {}; attrset = isStorePath {};