Modifying how package install path is validated
Fix: * This addresses a bug where nimble will throw an exception in the middle of installation due to trying to evaluate paths that are not normalized. This was fixed by adding some additional validation checks that involve comparing paths by normalizing them first. [#338]
This commit is contained in:
parent
e62084a2a7
commit
b7201c81a4
1 changed files with 8 additions and 1 deletions
|
|
@ -79,7 +79,14 @@ proc changeRoot*(origRoot, newRoot, path: string): string =
|
|||
## newRoot: /home/test/
|
||||
## path: /home/dom/bar/blah/2/foo.txt
|
||||
## Return value -> /home/test/bar/blah/2/foo.txt
|
||||
if path.startsWith(origRoot):
|
||||
|
||||
## The additional check of `path.samePaths(origRoot)` is necessary to prevent
|
||||
## a regression, where by ending the `srcDir` defintion in a nimble file in a
|
||||
## trailing separator would cause the `path.startsWith(origRoot)` evaluation to
|
||||
## fail because of the value of `origRoot` would be longer than `path` due to
|
||||
## the trailing separator. This would cause this method to throw during package
|
||||
## installation.
|
||||
if path.startsWith(origRoot) or path.samePaths(origRoot):
|
||||
return newRoot / path[origRoot.len .. path.len-1]
|
||||
else:
|
||||
raise newException(ValueError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue