layeh / asar Goto Github PK
View Code? Open in Web Editor NEWPackage asar reads and writes ASAR (Atom-Shell Archive) archives for Go (golang)
Home Page: https://godoc.org/layeh.com/asar
License: Mozilla Public License 2.0
Package asar reads and writes ASAR (Atom-Shell Archive) archives for Go (golang)
Home Page: https://godoc.org/layeh.com/asar
License: Mozilla Public License 2.0
I've found that opening an ASAR file and attempting to reencode it directly leads to issues on the archive format.
When attempting to decode an ASAR generated with this library, I get the following error;
invalid character '\x00' looking for beginning of value
Electron doesn't want to open this file either and asar
crashes with a stack error.
I suspect the header might be wrongly encoded.
I have a test scenario where reading an ASAR file generated by electron-builder "succeeds" but produces corrupt output.
Go code:
func TestAsar(t *testing.T) {
p := "/tmp/app.asar"
f, err := os.Open(p)
if err != nil {
t.Fatal(err)
}
e, err := asar.Decode(f)
if err != nil {
t.Fatal(err)
}
homeE := e.Find("public", "home.html")
r := homeE.Open()
b, err := ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
log.Printf("b: %s", b)
}
Produces output like:
=== RUN TestAsar
2017/06/26 16:43:43 b: tml>
<head>
.
.
.
</body>
</html>
<h
--- PASS: TestAsar (0.00s)
As you can see it has cut off 2 bytes at the start of the file and there are an extra 2 bytes at the end (I can't tell if those last two bytes are the 2 bytes of this same file or another html file).
The .asar file is 17mb and not something I want to post publicly but if you are able to take a look I can share with you on DropBox or other similar way.
Based on the given documentation/tests, I struggle implementing a way to encode and write the contents of a directory to an ASAR file.
Would it be possible to extend the documentation, as to make it more clear how to achieve writing ASAR files?
If there is addon in asar, it cannot be decompressed.
e.g: ps-list \ node-raw-socket
My asar contains these two packages, but after extracting them, the directory is empty:
I added some logs to the code, the code looks like this:
realPath := filepath.Join(target, path)
if entry.Flags&asar.FlagDir != 0 {
return os.MkdirAll(realPath, 0755)
}
if entry.Flags&asar.FlagUnpacked != 0 {
fmt.Println("x1")
fmt.Println(path)
fmt.Println(realPath)
return nil
}
The output of the console is:
When I use electron/asar, there is no problem
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.