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

SquashFsBuilder.File takes byte[] instead of Stream for the file content #2

Open
SuperJMN opened this issue Apr 2, 2024 · 4 comments

Comments

@SuperJMN
Copy link

SuperJMN commented Apr 2, 2024

Take this method invocation as an example:

SquashFsBuilder.File("dir/file1.txt", UTF8Encoding.UTF8.GetBytes("Oh yeah"), 0, 0, 0666);

The entry contents are taking from a byte[]. That could be a potential problem for large files. The whole byte[] needs to be allocated.
Using a Func<Stream> would be far better for the case because it would allow for huge files to be included.

I suggest a Func instead of just Stream because this way, the library can control the lifetime of the stream, properly creating it and disposing it when it's no longer needed (during the call to GetFilesystemImage())

@SuperJMN
Copy link
Author

SuperJMN commented Apr 2, 2024

The same applies to GetFileSystemImage itself, that returns byte[]. This is even worse, because if the image is big, the size of the byte[] could potentially cause memory issues.

@SuperJMN SuperJMN changed the title File method SquashFsBuilder takes byte[] instead of Stream for the file content SquashFsBuilder.File takes byte[] instead of Stream for the file content Apr 2, 2024
@teplofizik
Copy link
Owner

Thanks, I'll think about it =) I want to upgrade and speedup code of this library.

At now this library and application is using for rebuild and update small filesystems (~30 MB, embedded linux), for largest one it slow and not tested yet...

@SuperJMN
Copy link
Author

SuperJMN commented Apr 2, 2024

OK, I hope it evolves in the right direction. It looks straightforward to use! If you need any advice, please find me in Telegram @SuperJMN.

I'm making a very nice tool to distribute .NET applications and considered using DiscUtils, but it has a nasty bug and I had to look for alternatives. Your library looks fine!

@teplofizik
Copy link
Owner

Ok =)

I think, there is need to move NyaFs to separate repository

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

No branches or pull requests

2 participants