addurl --pathdepth: Fix failure when the pathdepth specified is deeper than the urls's path.

This commit is contained in:
Joey Hess 2013-07-05 12:46:38 -04:00
parent d84a000e92
commit 74ad3072e4
3 changed files with 9 additions and 0 deletions

View file

@ -151,6 +151,7 @@ url2file :: URI -> Maybe Int -> FilePath
url2file url pathdepth = case pathdepth of
Nothing -> filesize $ escape fullurl
Just depth
| depth >= length urlbits -> frombits id
| depth > 0 -> frombits $ drop depth
| depth < 0 -> frombits $ reverse . take (negate depth) . reverse
| otherwise -> error "bad --pathdepth"