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

Issue with relativePath formula in packer.ts code #14

Open
pachowe opened this issue Dec 6, 2024 · 0 comments
Open

Issue with relativePath formula in packer.ts code #14

pachowe opened this issue Dec 6, 2024 · 0 comments

Comments

@pachowe
Copy link

pachowe commented Dec 6, 2024

Hi,

Thanks for making this code available on GitHub.

I have been reviewing the code in "fragmenter-0.8.0", specifically the "packer.ts" code. I note that hash values are calculated using the relative, normalized folder names and the actual files themselves using Hasha. Specifically, here:

    if (stats.isFile()) {
        const relativePath = path.relative(absolutePath, baseDir);
        const normalizedPath = relativePath.replace(/\\/g, '/');
        return hasha(normalizedPath + await hasha.fromStream(fs.createReadStream(absolutePath)));

However, I believe the relativePath should be "const relativePath = path.relative(baseDir, absolutePath)" (i.e. reverse order) to produce values like "SimObjects/AirPlanes/FlyByWire_A380_842/aircraft.cfg" rather than "../..", "../../..", etc.

Although, the existing method works, I suspect the intent of the code is not strictly being followed. I have tested the existing code using the "pack.test.ts" code are retrieved the stated hash values.

Can you double check?

Many thanks,
Peter

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

1 participant