Skip to content

Incorrect integrity of transformed files? #277

Open
@toyobayashi

Description

asar/lib/filesystem.js

Lines 70 to 94 in c2b4777

const transformed = options.transform && options.transform(p)
if (transformed) {
const tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), 'asar-'))
const tmpfile = path.join(tmpdir, path.basename(p))
const out = fs.createWriteStream(tmpfile)
const readStream = fs.createReadStream(p)
await pipeline(readStream, transformed, out)
file.transformed = {
path: tmpfile,
stat: await fs.lstat(tmpfile)
}
size = file.transformed.stat.size
} else {
size = file.stat.size
}
// JavaScript cannot precisely present integers >= UINT32_MAX.
if (size > UINT32_MAX) {
throw new Error(`${p}: file size can not be larger than 4.2GB`)
}
node.size = size
node.offset = this.offset.toString()
node.integrity = await getFileIntegrity(p)

node.integrity = await getFileIntegrity(p)

p is original file path, while transformed file path is

const tmpfile = path.join(tmpdir, path.basename(p))

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions