Skip to content
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

Error for relpath on equal S3Paths #156

Open
bencottier opened this issue Nov 25, 2021 · 1 comment
Open

Error for relpath on equal S3Paths #156

bencottier opened this issue Nov 25, 2021 · 1 comment

Comments

@bencottier
Copy link

bencottier commented Nov 25, 2021

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.

@rofinn
Copy link
Owner

rofinn commented Nov 25, 2021

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

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

No branches or pull requests

2 participants