15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkFileInArchive = void 0;
const fs_1 = require("builder-util/out/fs");
const asar_1 = require("./asar");
/** @internal */
async function checkFileInArchive(asarFile, relativeFile, messagePrefix) {
    function error(text) {
        return new Error(`${messagePrefix} "${relativeFile}" in the "${asarFile}" ${text}`);
    }
    let fs;
    try {
        fs = await asar_1.readAsar(asarFile);
    }
    catch (e) {
        throw error(`is corrupted: ${e}`);
    }
    let stat;
    try {
        stat = fs.getFile(relativeFile);
    }
    catch (e) {
        const fileStat = await fs_1.statOrNull(asarFile);
        if (fileStat == null) {
            throw error(`does not exist. Seems like a wrong configuration.`);
        }
        // asar throws error on access to undefined object (info.link)
        stat = null;
    }
    if (stat == null) {
        throw error(`does not exist. Seems like a wrong configuration.`);
    }
    if (stat.size === 0) {
        throw error(`is corrupted: size 0`);
    }
}
exports.checkFileInArchive = checkFileInArchive;
//# sourceMappingURL=asarFileChecker.js.map