-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Support archive inspection #797
base: main
Are you sure you want to change the base?
Support archive inspection #797
Conversation
Ref #756 - apparently reading any files is a no-no |
Thanks for bringing that up - that would, of course, make this feature impossible to implement. Since I'd propose to hide this feature behind a special flag anyway, we could also say that the |
2a461ab
to
68fe930
Compare
I personnally doesn't care that much about that I was just saying back what was said on previous issues. But maybe feature flagging options that read files content (except for git) is a good idea. This is also debatable, do we prefer having it under a feature flag but still in the codebase or having it under a separate crate (still feature flagged). As for the silent fail, is it possible to replicate the broken link case to atleast show the error message on it ? |
Thanks for your thoughts on the topic - since I'm still early in development and don't really have a final design in mind yet, I can't really say much how easy that broken link/error message thing would be, but it sounds like a good idea. So then I'll go on and we can see later if we want to move the archive stuff into a separate crate. |
I'm following along... I just wanted to mention that I think using I also think it would be a useful future addition to attempt identification of archives by contents (i.e. |
7bb11c7
to
40c78d2
Compare
I finished a first proposal, if you want to have a look at it - it currently only consists of To avoid code duplication, I introduced a common trait for filesystem files ( I left a couple of Looking at the current implementation in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had time to review the code yet, but this did work with a .tar
archive, very cool!
It seems to not work on windows, could you try to gate it with a #[cfg(any(target_os = "macos", target_os = "linux"))]
to make it macos/linux only? That should resolve the CI issues.
Gonna take a look at the code, but this seems promising, I think bringing this is a great advancement. |
The changes make the Windows build very broken because the refactoring requires Out of scope but on Windows, ZIP inspection would be much more useful than tar. How useful is uncompressed tar inspection? I thought most tars that people would come across would be compressed in some way. |
It's a good start - compression can be figured out later, I'm sure. I can foresee inspection of tar, cpio (and RPM as a special case of cpio), ar (.a archive), and zip as being the most important. Eventually it would be nice to see 7z, pax, ISO, CAB, rar, and lha support, and support for decompressing various streaming "outer" compression methods (lzip, bzip2, gzip, compress, etc.) (I'd normally use libarchive for something like this, if I was working in C.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review on my side, I have some thoughts, that are debatable, on the options part and how its managed.
src/options/flags.rs
Outdated
@@ -82,6 +82,7 @@ pub static OCTAL: Arg = Arg { short: Some(b'o'), long: "octal-permis | |||
pub static SECURITY_CONTEXT: Arg = Arg { short: Some(b'Z'), long: "context", takes_value: TakesValue::Forbidden }; | |||
pub static STDIN: Arg = Arg { short: None, long: "stdin", takes_value: TakesValue::Forbidden }; | |||
pub static FILE_FLAGS: Arg = Arg { short: Some(b'O'), long: "flags", takes_value: TakesValue::Forbidden }; | |||
pub static INSPECT_ARCHIVES: Arg = Arg { short: Some(b'q'), long: "quasi", takes_value: TakesValue::Forbidden }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAy I ask the reason of --quasi
? I think its okay as a name but I don't get the link with archives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's derived from AIX's li
program, to treat archives as "quasi-directories".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer this to be --inspect-archives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a preference tbh so its up to you all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't have a strong opinion, although I think having a short flag for it would be great - but in the end, this can also be solved via a shell alias.
Maybe 🎉 for --quasi
and 🚀 for --inspect-archives
(or other suggestions)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/*
* li - list files, directories, archives
*
Rewritten by D. Landauer to combine the functions of seven different
`ls' programs we had here (May '79) ... also made it use stdio. Flags:
-I<abcfghilmnoprsu> include a field
-E<abcfghilmnoprsu> exclude a field **rrr**
accessed-time headers modified-time protections
character count i-number name size (in blocks)
group id link count owner id updated-time
-O<abcdfpsx> list only these types of files
archives directories symbolic links
block devices files (normal) executable files
character devices pipes (fifos)
-S[r]<acmnsux> sort order [r= reversed]
accessed-time (latest first) name (default)
modified-time (latest first) size (biggest first)
updated-time (latest first) x = no sort at all
-R[<n>anqp] recursive, to level n
a absolute pathnames
n don't list qdirs' contents (default)
p pathnames (relative)
q do list qdirs' contents
-<n> at most n columns
-a all files
VMS: all versions of files
other: even ones beginning w/ `.'
-d directories (not their contents)
-f force interpretation as a directory
-l local long form (-Icglmnop)
-k remote long form (-Ibcfmnpr) * removed *
-n real file names: do not make them printable (==> -1)
-s sortable verbose (Berklix style)
-v visual/verbose
-x extended (-Iabcfgilmoprsu)
-L follow symbolic links (default is to not follow)
Routines are in alpha order except main & init (the first two) and
getpwn, getgrpn and search (the last three). Throughout, I refer to
archives as "quasi-directories", often abbreviated as qdirs.
(Quasi-directories are a superset of directories.)
Because of the removal of the Distribution Services, the following
options will be affected:
1) -k option is removed.
2) -Ibfr options are ignored, but it will display '-'s instead.
3) -Ebfr options are ignored.
4) -x option is affected. It will display '-' for -bfr fields.
*/
The IBM li
program that treats archives as "quasi-directories" goes back to the late 70's at least, so maybe it is set in muscle memory of people. Although I do like -q
/--quasi
myself, it's not something I'm too worried about. :)
Thanks, didn't look at Windows yet at all. Will fix the CI and the other review comments this weekend.
I will take a look at the Windows long output and how the permissions are displayed there, but don't really have any kind of Windows development setup to test it in a live environment. Hints on how to solve potential incompatibilities would be appreciated.
It's mainly as a proof-of-concept since the format is pretty easy to deal with.
Fair point, I actually found https://github.com/fnichol/libarchive-rust as a Rust wrapper, but last commit was 6 years ago and not sure if we want to add that as an dependency. |
b136f4f
to
7ea3793
Compare
I've tested it on Windows and it works but only seems to read a .tar file if it's specified explicitly, is that intentional? That is, if I specify |
e0d960b
to
9e18ec7
Compare
Actually, I forgot that and only had explicitly specified tar archives in mind. Do you think that's an actual use case? Edit: I just pushed a draft that archives are also inspected in combination with |
b48d5ab
to
25f05ae
Compare
That is strange cause as of what I know tree is the same as -R for most part |
You can take a look at 60bdedd, I added a Or are there any other opinions if the archive inspection should also work for not explicitly specified archives? |
Okay nice didnt catch that |
We were chatting about feature gates in the Matrix channel earlier and I think that if we're going to introduce compressed archive inspection in the future it would probably make sense to put that behind a feature gate because it'll pull in compression libraries. Which, by extension, means that this feature should probably be feature gated too so we don't have to either break it when we gate it later, or explain that inspection of some archives is enabled by a feature. I also think the feature should be enabled by default, though. |
c12447e
to
03ed232
Compare
@daviessm I agree regarding the feature flag - do you want to take a look at 1dffecb if you think that's what you meant? At first, I tried to actually remove every part of the code containing Otherwise, I hopefully incorporated the other feedback as well - but feel free to give additional feedback. The only thing I'm still struggling with is the nix environment that somehow fails to compile |
Yeah that makes sense, the only other thing is I think we should remove the help text too but I don't think we do that for |
Fair point, looks like I forgot to add the flags to the help text altogether. I added it to the display options in 50d6221. |
2ea37dd
to
a79f904
Compare
a79f904
to
9eff928
Compare
9eff928
to
10be86d
Compare
@cafkafk @MartinFillon ping, not entirely sure who else to ping. I rebased the PR so that we can maybe get it ready for merge - but feel free to nitpick as much as you want. Some help with the CI would be appreciated, but I don't think any change in this PR broke the BSD workflows. |
Description
This PR introduces a new flag (currently
-q
and--quasi
as suggested in the linked issue) to allow to list the content of archives. If a file is an archive is solely determined based on the file extension for now.For now, I only added support for
.tar
archives, but the changes aim to lay the foundation for the future support of additional archive formats.Resolves #600
How Has This Been Tested?
TODO