Open xfzv opened 2 weeks ago
Any chance the extract feature could be more optimized? In this case,
tar
is definitely more suitable than7z
.
I think this is possible, but I have a few questions/concerns:
* What about Windows users?
After a quick research, it doesn't seem that tar
is natively available for MS Windows. Found Tar for Windows but it's completely out-of-date (2003) so it's probably not relevant. Correct me if I'm wrong, maybe a maintained port exists.
Edit: tar
is actually available out-of-the-box on MS Windows, see https://github.com/sxyazi/yazi/issues/1548#issuecomment-2309999382
* Is tar available on all platforms (such as NixOS as well)? Do we need to add it to Yazi's dependency list?
It seems that it's available as gnutar
for NixOS and with brew
too.
* Can tar provide an efficient archive preview feature? We need to make sure that the content users preview matches the content that's ultimately extracted. 7zip only previews the outer structure, so if we use 7zip to preview tar extractions, it might confuse users.
Using -t, --list
:
man 1 tar
-t, --list List the contents of an archive. Arguments are optional. When given, they specify the names of the members to list.
Using the provided tar.gz
example:
% tar -tf viddy-v1.0.1-linux-x86_64.tar.gz
viddy
Note that unlike 7z
, it only works for tar
archives:
% tar -tf test.zip
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
- What if the user has only installed tar or 7zip (considering both extraction and preview)?
Considering both tools can preview/extract, just use the one installed I guess? Since tar
doesn't seem to be available on MS Windows (again, I might be wrong), 7z
would be the only option for Windows users.
Edit: tar
is actually available out-of-the-box on MS Windows, see https://github.com/sxyazi/yazi/issues/1548#issuecomment-2309999382
Windows 10 and 11 come with tar.
Links
Windows 10 and 11 come with tar.
Links
* [The Windows Process Journey — tar.exe (BSD tar Archive Tool)](https://medium.com/@boutnaru/the-windows-process-journey-tar-exe-bsd-tar-archive-tool-d307a4412c46) * [How to extract .tar.gz files on Windows 11](https://pureinfotech.com/extract-tar-gz-files-windows-11/)
Thanks for the info, I didn't know that. I've just tried on a Windows 10 VM, -t, --list
seems to work just fine:
% C:\Users\User\Downloads> tar -tf viddy-v1.0.1-linux-x86_64.tar.gz
viddy
Thanks for the info! I think it's worth a try.
Is anyone interested in implementing it? If it's simple enough and doesn't add too much maintenance overhead (let's say <100 lines), I'd be open to accepting a PR.
The code for the extract
plugin is here: https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/extract.lua
Hi, @xfzv .
Can you tell a bit more about steps to reproduce? I'm using Arch Linux and have deleted the ~/.config/yazi
to use the default extract opener. But heres what happened: I only gets a dir called viddy-v1.0.1-linux-x86_64
with a file viddy-v1.0.1-linux-x86_64.tar
in it. And the state in the right corner shows the task is processing 99%.
Check out here: reproduce preview.
Update: After restarting my computer, the 99% disappeared, but the dir still looks the same.
@DirkFi I've just tried on my Arch Linux install and it behaves as I mentioned in OP, the extract task isn't stuck and I eventually have the viddy
binary.
And the state in the right corner shows the task is processing 99%.
If you manage to get the task stuck at 99% again, open the task manager and press Enter to see more details about it.
I assume you do have Edit: Sorry, I meant tar
installed considering it's in the base
group?p7zip
Can you try with another tarball maybe?
Which version of yazi
are you using? As far as I'm concerned:
% yazi -V
Yazi 0.3.2 (ddb8ce5 2024-08-28)
Anything in ~/.local/state/yazi/yazi.log
?
@xfzv
I did not see any useful info in log file. My version is 0.3.1 and i also tried to install from the source code which was just now updated to 0.3.2 but still got similar results.
And, yes, I have p7zip installed and can run 7z command. Maybe I need to try another tarball.
Sorry about the misunderstanding, seems that I misunderstands your point. The image I shared with you actually reproduced the problem but I did not notice that and thought it was not the issue. Right now I understand that the issue is for tar.gz file it needs to unzip twice to get the original file and create some redundant dirs.
BTW, how to open the task manager inside Yazi?
BTW, how to open the task manager inside Yazi?
With w
:
https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml#L146-L147
What system are you running Yazi on?
Linux X11
What terminal are you running Yazi in?
kitty 0.35.2
yazi --debug
outputDid you try the latest nightly build to see if the problem got fixed?
Yes, and I updated the debug information above (
yazi --debug
) to the nightly that I triedDescribe the bug
When extracting a
tar.gz
archive that contains a single file in it (no directory):with default
extract
openerhttps://github.com/sxyazi/yazi/blob/69c20d4dd3df49b22d80b11d63b35e8a914475bb/yazi-config/preset/yazi.toml#L49
Here's what happens:
archive
)archive.tar
file is created insidearchive
directoryEnter
to extract thearchive.tar
file, another directory calledarchive
is createdarchive
directory, we finally havebinary
binary
file permissions are not preserved (644, is actually 755)The final file hierarchy structure:
I'm aware this is the default
7z
behavior (can reproduce with7z x archive.tar.gz
) but this is really not convenient. With:the binary is directly extracted to the current directory and permissions are preserved.
Any chance the extract feature could be more optimized? In this case,
tar
is definitely more suitable than7z
.Minimal reproducer
tar.gz
file~/.config/yazi
directory, reproduce steps detailed inDescribe the bug
to extract thetar.gz
archive and observe the final file structureAnything else?
No response