FilePathsBase.jl
FilePathsBase.jl copied to clipboard
Error for `relpath` on equal S3Paths
MWE:
julia> using AWSS3, FilePathsBase
julia> dir = p"s3://some/dir/";
julia> relpath(dir, dir)
ERROR: ArgumentError: . cannot be parsed as S3Path{Nothing}
Stacktrace:
[1] #parse#6
@ ~/.julia/packages/FilePathsBase/qgXdE/src/path.jl:79 [inlined]
[2] parse
@ ~/.julia/packages/FilePathsBase/qgXdE/src/path.jl:78 [inlined]
[3] relative(fp::S3Path{Nothing}, start::S3Path{Nothing})
@ FilePathsBase ~/.julia/packages/FilePathsBase/qgXdE/src/path.jl:447
[4] relpath(fp::S3Path{Nothing}, src::S3Path{Nothing})
@ FilePathsBase ~/.julia/packages/FilePathsBase/qgXdE/src/aliases.jl:22
[5] top-level scope
@ REPL[54]:1
This is an odd thing to do directly. But it comes up if e.g. you are doing a walkpath(dir)
where one of the files is directly in dir
(call its path filepath
). And then you want the relpath(dirname(filepath), dir)
.
I believe it doesn't work because this package will call tryparse(S3Path, ".")
in this case and AWSS3 tryparse
returns nothing
if the path doesn't have the s3://
URI. So I'm not sure which package should be responsible.
Hmm, I suppose we could special case if there's a drive, since there does seem to be precedent for that in the base Julia docs now?
If path and startpath refer to different drives, the absolute path of path is returned.
In that case, the drive would be copied to the result and only the segments would be modified (e.g., s3://.
). I haven't looked into whether this changed though, cause previously base julia ignored drives in relative paths.
https://github.com/rofinn/FilePathsBase.jl/blob/master/src/path.jl#L478