Skip to content
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

resolve end header not found #1018

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wagyourtail
Copy link

@wagyourtail wagyourtail commented Apr 26, 2023

resolves #933

it appears that with thunderstore app, the end of the zip gets padded with a bunch of 0's after for some reason.
I would guess this is an issue with padding on their buffer that they just write instead of trimming first.

image
the zip reader doesn't like that

this pr fixes that by ensureing the zips are trimmed

@CLAassistant
Copy link

CLAassistant commented Apr 26, 2023

CLA assistant check
All committers have signed the CLA.

@MythicManiac
Copy link
Collaborator

Good find! The current implementation seems to load the entire zip to memory before writing it back to disk, which is potentially a bad idea to do as some profile exports can be quite large. I can't immediately think of a good way to address that, but we might be able to fix how zip creation works on the other mod manager & ensure it doesn't create trailing zeroes at least in the meanwhile.

@wagyourtail
Copy link
Author

wagyourtail commented Apr 27, 2023

well. the FsProvider doesn't wrap the fs functions for streaming file content... or fs.truncate. maybe if I add them...

@wagyourtail
Copy link
Author

done

Copy link
Owner

@ebkr ebkr left a comment

Choose a reason for hiding this comment

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

Added a few comments, thanks for the contribution! Sorry for the delayed response.

src/pages/Profiles.vue Show resolved Hide resolved
src/pages/Profiles.vue Outdated Show resolved Hide resolved
src/pages/Profiles.vue Outdated Show resolved Hide resolved
src/pages/Profiles.vue Outdated Show resolved Hide resolved
src/providers/generic/file/NodeFs.ts Show resolved Hide resolved
@MythicManiac
Copy link
Collaborator

The real blocker with the PR is that on TMM the I/O implementation is done by a C# plugin, and we can't pass complex types through that IPC layer, including streams I believe. In other words, this has to be implemented in some fashion that avoids passing complex types to/from the FS provider.

One option would be to implement the whole zip preprocessing logic in the FS provider, which we can keep as a stub on the C# plugin since the C# code already is able to handle the zips as is.

@wagyourtail
Copy link
Author

wagyourtail commented May 17, 2023

The real blocker with the PR is that on TMM

It's fixed here, so I don't see why fixing in on TMM would block this PR seeing as this is the fix for the issue on this end, and doesn't rely on TMM fixing it.

@MythicManiac
Copy link
Collaborator

MythicManiac commented May 18, 2023

It's fixed here, so I don't see why fixing in on TMM would block this PR seeing as this is the fix for the issue on this end, and doesn't rely on TMM fixing it.

It's because the same code runs on both for a large portion of the core mod install logic to keep mod installs consistent between the two. In other words, we'll need to make similar adjustments to the filesystem provider implementation on TMM as was done here or the build breaks. And as things currently are implemented, I don't think it's possible to do due to the C# interop layer not supporting complex types.

So I'd suggest moving the current sanitizeImportEndHeader functionality to the FsProvider, e.g. as a function called sanitizeZip which takes in a filepath as a parameter and truncates it in-place. That way there's no need to pass complex types through the interop layer on TMM but the fix also works here.

@ebkr
Copy link
Owner

ebkr commented May 20, 2023

@wagyourtail For context, r2modman is a git submodule that TMM uses, so the code internally isn't actually modifiable from TMM's end. We use a "provider" that lets TMM override behaviour of certain areas. So by having the code in the provider TMM can avoid using it and use the C# layer which works as intended.

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.

[BUG] - Import Code Fails with "Invalid or unsupported zip format. No END header found"
4 participants