-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add has_symlink public API function #166
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #166 +/- ##
==========================================
+ Coverage 97.28% 97.55% +0.26%
==========================================
Files 4 4
Lines 810 817 +7
==========================================
+ Hits 788 797 +9
+ Misses 22 20 -2 ☔ View full report in Codecov by Sentry. |
@nhz2 's implementation looks good as well: |
This feels like it could be implemented externally since it's quite a simple application of has_symlink = false
Tar.list(tarball) do hdr
has_symlink |= hdr.type == :symlink
end If anything, I'd be inclined to add a generic predicate checker like this: Tar.check_any(predicate::Function, tarball::ArgRead) That checks if any entry in the tarball satsifies a predicate; it could be specialized with a |
How would one write a function without getting into the non-public details of the header structure? If Also I don't get the need to |
The |
We could add short-circuiting as an optimization if we have a |
How about we define |
Here is the API I am imagining. julia> open(GzipDecompressorStream, "P4est.v2.8.1.x86_64-w64-mingw32-mpi+microsoftmpi.tar.gz") do io
findfirst(islink, Tar.list(io)) != nothing
end
true
julia> Tar.create(mkdir("empty"), "foo.tar")
"foo.tar"
julia> findfirst(islink, Tar.list("foo.tar")) != nothing
false For the short-circuiting what I really want is a lazy iterator over the headers rather than the eager |
I've made a PR for the predicates on Header types: https://github.com/JuliaIO/Tar.jl/pull/169/files. Making an iterable object that does what |
Please also note that none of this is going to help the Pkg situation since I don't think we want to add faetures to Tar in a point release and a point release is what is where this issue is going to be fixed. |
Implement
Tar.has_symlink
as requested by @staticfloatxref: JuliaLang/Pkg.jl#3643 (comment)