Code Monkey home page Code Monkey logo

Comments (6)

zkochan avatar zkochan commented on June 12, 2024 2

We should fix this. Here's the reason:

Our in-house tarball extractor currently skips symlinks.

from pnpm.

zkochan avatar zkochan commented on June 12, 2024 2

This PR should fix it: #7705

from pnpm.

zkochan avatar zkochan commented on June 12, 2024 1

Thanks @bitofsky for look into it. We will for sure backport the fix to v8 too. We just need to cover it with a test. I don't want us to break it again in the future.

from pnpm.

zkochan avatar zkochan commented on June 12, 2024

No, actually it is a problem with side-effects cache. When we upload side-effects cache to the store, we don't upload symlinks correctly, I guess. I get the same issue with pnpm v8.6.12

from pnpm.

zkochan avatar zkochan commented on June 12, 2024

I assume this issue is the same as #7253

from pnpm.

bitofsky avatar bitofsky commented on June 12, 2024

@zkochan Hello? I have found an issue in cafs/src/addFilesFromDir.ts.
In version pnpm 8.6.12, symbolic links are recognized as files, but starting from version pnpm 8.7.0, symbolic links are not recognized as files anymore.
The changes between the two versions are as follows:

[email protected]

    const files = await fs.readdir(currDir) // readdir returns an array of strings
    await Promise.all(files.map(async (file) => {
      ...
      const stat = await fs.stat(fullPath) // stat returns a Stats object
      if (stat.isDirectory()) {
        ...
      }
      if (stat.isFile()) { // symbolic links are considered files

[email protected]

    const files = fs.readdirSync(currDir, { withFileTypes: true }) // readdirSync returns an array of Dirent objects
    for (const file of files) {
        if (file.isDirectory()) {
            ...
        }
        if (file.isFile()) { // symbolic links are not considered files
            ...
        }

Dirent objects and Stats objects return different results when the isFile() method is called on symbolic linked files.
While Dirent objects return false when the isFile() method is called on symbolic linked files, Stats objects return true.

10272392 -rw-rw-r-- 1 bitofsky bitofsky  2 Feb 23 16:06 origin.txt
10272393 lrwxrwxrwx 1 bitofsky bitofsky 10 Feb 23 16:09 link.txt -> origin.txt
> node
> require('fs').readdirSync('.', {withFileTypes:true}).find(f => f.name === 'link.txt').isFile() // readdirSync returns an array of Dirent objects
false
> require('fs').statSync('./link.txt').isFile() // statSync returns a Stats object
true

However, starting from [email protected], symbolic links are correctly recognized again.
The code checking for isFile() in the if condition has been removed and replaced with else.

    const files = fs.readdirSync(dir, { withFileTypes: true })
    for (const file of files) {
        if (file.isDirectory()) {
            ...
        } else { // symbolic links are considered files
            ...
        }

I believe the code modified in version 9.0.0-alpha.5 should be reflected in the version 8 series as well, or the code after 8.7 should be modified as follows.

-       } else if (file.isFile()) {
+       } else if (file.isFile() || file.isSymbolicLink()) {

Thank you.

from pnpm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.