Skip to content

feat: lz and lz4 archives support#3451

Closed
yh-sb wants to merge 2 commits into
sxyazi:mainfrom
yh-sb:main
Closed

feat: lz and lz4 archives support#3451
yh-sb wants to merge 2 commits into
sxyazi:mainfrom
yh-sb:main

Conversation

@yh-sb

@yh-sb yh-sb commented Dec 20, 2025

Copy link
Copy Markdown

Which issue does this PR resolve?

Add support of .lz and .lz4 archives

Rationale of this PR

.lz and .lz4 should be supported as well as others

@sxyazi

sxyazi commented Dec 20, 2025

Copy link
Copy Markdown
Owner

Thanks for the patch! A few questions:

  • What's the MIME type of .lz and .lz4 exactly? Why is a wildcard (e.g. *lzip) needed?
  • Can you provide a .lz and .lz4 file so that I can test them locally?

@yh-sb

yh-sb commented Dec 21, 2025

Copy link
Copy Markdown
Author

@sxyazi, I tested the real MIME types for .lz and .lz4

$ tar --lzip -cf archive.tar.lz file.pdf
$ file --mime-type ./archive.tar.lz4
./archive.tar.lz4: application/x-lz4

$ tar -cvf - file.pdf | lz4 > archive.tar.lz4
$ file --mime-type ./archive.tar.lz
./archive.tar.lz: application/x-lzip

Here are files examples: archive.tar.lz, archive.tar.lz4

Also I reworked the fix to use these MIME types. The one thing I'm not sure about is the diff in yazi-plugin/preset/plugins/extract.lua.
Do we really need all these three lzip = true, lz = true, lz4 = true,?

@sxyazi

sxyazi commented Dec 22, 2025

Copy link
Copy Markdown
Owner

I tried lz and lz4 previews with this PR, but it errors out:

ERROR: archive.tar.lz4 : Cannot open the file as archive

And when I extract lz and lz4 files encountered the same Cannot open the file as archive error.

@yh-sb

yh-sb commented Dec 22, 2025

Copy link
Copy Markdown
Author

Are you using ouch for this?

@sxyazi

sxyazi commented Dec 22, 2025

Copy link
Copy Markdown
Owner

No I'm using 7zip. Run 7zz l without/outside of Yazi produces the same error:

❯ 7zz l archive.tar.lz4

7-Zip (z) 25.01 (arm64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
 64-bit arm_v:8.5-A locale=en_US.UTF-8 Threads:8 OPEN_MAX:2560, ASM

Scanning the drive for archives:
1 file, 580099 bytes (567 KiB)

Listing archive: archive.tar.lz4


ERROR: archive.tar.lz4 : Cannot open the file as archive



Errors: 1

@yh-sb

yh-sb commented Dec 23, 2025

Copy link
Copy Markdown
Author

Then something wrong with 7zz.

lz4 and lzip support it:

$ lz4 -d ./archive.tar.lz4
Decoding file ./archive.tar 
./archive.tar.lz4              : decoded 593920 bytes

$ lzip -dk ./archive.tar.lz
$ ls -la ./archive.tar
-rw-r--r--@ 1 y  staff  586240 Dec 23 11:45 ./archive.tar

Latest ouch (nightly build from main branch) supports it:

$ ouch list ./archive.tar.lz4
Archive: /Users/y/Downloads/archive.tar.lz4
._p1539-orlov.pdf
p1539-orlov.pdf

$ ouch list ./archive.tar.lz
Archive: /Users/y/Downloads/archive.tar.lz
._p1539-orlov.pdf
p1539-orlov.pdf

7z also handles .lz (lzip) and .lz4 correctly:

$ 7z l ./archive.tar.lz

7-Zip [64] 17.05 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.05 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,14 CPUs LE)

Scanning the drive for archives:
1 file, 575105 bytes (562 KiB)

Listing archive: ./archive.tar.lz

--
Path = ./archive.tar.lz
Type = lzip

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
                    .....                            archive.tar
------------------- ----- ------------ ------------  ------------------------
                                             575105  1 files
$ 7z l ./archive.tar.lz4

7-Zip [64] 17.05 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.05 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,14 CPUs LE)

Scanning the drive for archives:
1 file, 580099 bytes (567 KiB)

Listing archive: ./archive.tar.lz4

--
Path = ./archive.tar.lz4
Type = lz4

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
                    .....                            archive.tar
------------------- ----- ------------ ------------  ------------------------
                                             580099  1 files

@sxyazi

sxyazi commented Dec 23, 2025 via email

Copy link
Copy Markdown
Owner

@yh-sb

yh-sb commented Dec 23, 2025

Copy link
Copy Markdown
Author

I didn't know yazi used 7zz.

@sxyazi

sxyazi commented Dec 23, 2025

Copy link
Copy Markdown
Owner

Closing in that case, thank you for the effort anyway!

@sxyazi sxyazi closed this Dec 23, 2025
@yh-sb

yh-sb commented Dec 24, 2025

Copy link
Copy Markdown
Author

Then something wrong with 7zz.

I created a fix for 7zz to support .lz and .lz4: ip7z/7zip#177.

When it will be merged - we can come back to this PR in yazi.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants