Open titpetric opened 7 years ago
If I create my own zip and do this, it seems to work, regardless of what rice append
produces:
zip -r data.zip assets/ templates/
cat data.zip >> binary-file
zip -A binary-file
So it seems there should be just some step in rice append
that would produce a compressed zip file, which can already be read by rice?
& there are some issues in regards how folders are added to the archive. Unpacking the binary file doesn't work nicely if the data is appended with the rice command. Boxes/folders are unpacked as 0 byte files.
I just noticed this as well when my compiled variant was 115mb and the zip appended executable was 137. The files, alone, are 130mb, and when zipped are 11mb (yay xml...).
Doing some basic research, I think this line (https://github.com/GeertJohan/go.rice/blob/master/rice/append.go#L111) is missing a follow up line of
zipFileHeader.Method = zip.Deflate
I added that and rebuilt and the appended file now is 19mb (8 for the app pre-append + the 11 I expect) so it looks to, file size, work. However, running the app throws several errors and truncates the embedded files, so clearly the reading back of a compressed archive is also incompatible still.
./application
2016/11/26 10:29:20 error reading data for appended file path/to/file1: EOF
2016/11/26 10:29:20 error reading data for appended file path/to/file2: EOF
2016/11/26 10:29:20 error reading data for appended file path/to/file3: EOF
...etc
@jeffminard-ck - I suggest you to try my workaround in comment 2 with zip -A and let me know if you can bypass append and end up with a working app :)
I did eventually try that and ended up with the same results. The readback code I could find doesn't seem to mention zip.Deflate
anywhere so I suspect it doesn't read the archive contents back correctly. I got a lot of half-complete responses and weird behavior.
Hello
I ran into the same problem. The size of the executable file grows too much because there is no compress option, I have made some changes that allow deflate to be used in the boxes, both as appended and embedded.
I have found that the main problem was due to a problem in the implementation of the algorithm in flate
If you use rc.Read to read the content in a compressed file you will get an EOF error. Then I use ioutil.ReadAll it doesn't generate the error and you don't need make the slice, and to make sure the uncompressed file content is correct it calculate CRC and compare with the store one.
There is a new flag "/c" that allows compress. If the flag is not used the previous process is generated. The boxes are compatible with previous version without changes
I have made a fork on https://github.com/wladiz2001/go.rice/
You can review it and if there is no problem you can merge it
Appending two boxes (templates and assets folder), I can inspect the binary files and realize that the appended data is not compressed at all:
I'm expecting the zip file would be compressed which doesn't seem to be the case...