10000 feat(archive): support multipart archives by KirCute · Pull Request #8184 · AlistGo/alist · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(archive): support multipart archives #8184

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

Merged
merged 6 commits into from
Mar 27, 2025

Conversation

KirCute
Copy link
Contributor
@KirCute KirCute commented Mar 21, 2025

Support multipart archives in Zip (with suffix like .zip.001), RAR (with suffix like .part1.rar) and 7zip (with suffix like .7z.001) formats.
Rewrite RAR tool in nwaples/rardecode to support encrypted archives.
Rewrite 7zip tool in bodgit/sevenzip to support encrypted archives.
Support decompressing multiple selected files.

Front-end part: AlistGo/alist-web#263.

Close #8015

Copy link

Walkthrough

This PR introduces support for multipart archives in RAR and 7zip formats, including handling encrypted archives. It rewrites the RAR tool using nwaples/rardecode and the 7zip tool using bodgit/sevenzip, and adds functionality for decompressing multiple selected files.

Changes

Files Summary
go.mod Updated dependencies for nwaples/rardecode and bodgit/sevenzip.
internal/archive/all.go Added imports for new RAR and 7zip handling packages.
internal/archive/archives/archives.go Modified methods to handle multiple streams for multipart archives.
internal/archive/iso9660/iso9660.go Adjusted methods to support multiple streams.
internal/archive/rardecode/* New package for handling RAR archives, including multipart and encrypted files.
internal/archive/sevenzip/* New package for handling 7zip archives, including multipart and encrypted files.
internal/archive/tool/* Refactored tool interface and helper functions to support multipart archives.
internal/archive/zip/* Updated zip handling to use new tool interface.
internal/driver/driver.go Minor comment adjustments.
internal/fs/archive.go Refactored to use new archive tool and stream handling.
internal/op/archive.go Refactored to support multipart archive streams.
internal/stream/* Added support for handling multiple streams and improved closing logic.
server/handles/archive.go Updated request handling to support multiple archive names.

}, nil
}

func (RarDecoder) List(ss []*stream.SeekableStream, args model.ArchiveInnerArgs) ([]model.Obj, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The List function for RarDecoder currently returns errs.NotSupport. If listing files within the archive is a required feature, this needs to be implemented to avoid functionality gaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是正常的,List返回errs.NotSupport时,op包会调用GetMeta得到文件列表。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在这机器人这么智能了吗 😹

}, nil
}

func (SevenZip) List(ss []*stream.SeekableStream, args model.ArchiveInnerArgs) ([]model.Obj, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The List function for SevenZip currently returns errs.NotSupport. If listing files within the archive is a required feature, this needs to be implemented to avoid functionality gaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@Clouddark75
Copy link

Oh, cool! Thanks for sparing some time to add these options.

@Clouddark75
Copy link
Clouddark75 commented Mar 26, 2025

I don't know if there's something wrong on my end, but I can't view or decompress files with the builds from this PR: https://github.com/AlistGo/alist/actions/runs/14073797065

Is there a new option that I haven't seen that I should enable from now on? @KirCute

@KirCute
Copy link
Contributor Author
KirCute commented Mar 26, 2025

Is there a new option that I haven't seen that I should enable from now on? @KirCute

There is one frustrating quirk of the build system: when a PR contains both frontend and backend changes, it still builds the frontend using the latest main branch version (instead of the unmerged PR changes).

This caused an issue in my update: I modified the frontend's logic for detecting archived files (to support multipart ones), but since the build used the old frontend code (instead of AlistGo/alist-web#263), it now treats every file as non-archived based on the backend’s new response. As a result, the Archive Preview won’t show up at all.

@Clouddark75
Copy link

Is there a new option that I haven't seen that I should enable from now on? @KirCute

There is one frustrating quirk of the build system: when a PR contains both frontend and backend changes, it still builds the frontend using the latest main branch version (instead of the unmerged PR changes).

This caused an issue in my update: I modified the frontend's logic for detecting archived files (to support multipart ones), but since the build used the old frontend code (instead of AlistGo/alist-web#263), it now treats every file as non-archived based on the backend’s new response. As a result, the Archive Preview won’t show up at all.

Oh, I see. I kind of figured out that could be the problem, but I was not that sure if it was only that at all. Thanks for the quick response, as usual!

Oh, and .z00, .z01, etc. are another suffix that zip part files have; some old compressors use this instead of .zip.001, .zip.002, etc.

@KirCute
Copy link
Contributor Author
KirCute commented Mar 26, 2025

Oh, I see. I kind of figured out that could be the problem, but I was not that sure if it was only that at all. Thanks for the quick response, as usual!

Oh, and .z00, .z01, etc. are another suffix that zip part files have; some old compressors use this instead of .zip.001, .zip.002, etc.

8000

During testing, I found that multipart archive files with suffixes like .z00 don't seem to form a complete recognizable archive by simply concatenating them sequentially—similar to .part1.rar files. Unfortunately, I haven’t found a library that supports the .z00 format like RAR does. I could try simply treating them as .zip.001 files, but they likely won’t work as expected.

It’s 00:45 GMT+8 now, and I’ll add .z00 to the list of valid multipart suffixes after getting a sleep.

@Clouddark75
Copy link

Oh, I see. I kind of figured out that could be the problem, but I was not that sure if it was only that at all. Thanks for the quick response, as usual!
Oh, and .z00, .z01, etc. are another suffix that zip part files have; some old compressors use this instead of .zip.001, .zip.002, etc.

During testing, I found that multipart archive files with suffixes like .z00 don't seem to form a complete recognizable archive by simply concatenating them sequentially—similar to .part1.rar files. Unfortunately, I haven’t found a library that supports the .z00 format like RAR does. I could try simply treating them as .zip.001 files, but they likely won’t work as expected.

It’s 00:45 GMT+8 now, and I’ll add .z00 to the list of valid multipart suffixes after getting a sleep.

I see that you already checked it out, but yah not really a necessity. Most of the time for what I have tested remaining them could do the work.

Have a good rest!

@xhofe xhofe merged commit 1335f80 into AlistGo:main Mar 27, 2025
12 checks passed
@KirCute KirCute deleted the feat/multipart-archive branch March 27, 2025 15:22
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

Successfully merging this pull request may close these issues.

解压带密码的RAR和7Z时提示密码错误
4 participants
0