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

hidefile file not found error with folder in Windows #3

Open
PsyKoMari opened this issue May 16, 2018 · 6 comments
Open

hidefile file not found error with folder in Windows #3

PsyKoMari opened this issue May 16, 2018 · 6 comments

Comments

@PsyKoMari
Copy link

PsyKoMari commented May 16, 2018

I'm getting a list of filesystem files and folder, and wont list hidden files/directory.

I'm exploring the filesystem by var files = fs.readdirSync(testFolder); and for every entry in this folder I

var actualFile = path.join (testFolder , file);
if (!hidefile.isHiddenSync(actualFile)) {
    //append to array
}

With files is ok but with folders i got this error:

Error: Impossibile trovare il file
    at get_parseResult (C:\Git\merish5web\node_modules\winattr\lib\shell\index.js:44:12)
    at Object.getSync (C:\Git\merish5web\node_modules\winattr\lib\shell\index.js:148:11)
    at C:\Git\merish5web\node_modules\winattr\lib\index.js:27:30
    at Object.run (C:\Git\merish5web\node_modules\winattr\lib\whichLib.js:74:12)
    at Object.getSync (C:\Git\merish5web\node_modules\winattr\lib\index.js:25:19)
    at statSync (C:\Git\merish5web\node_modules\hidefile\index.js:131:28)
    at Object.isHiddenSync (C:\Git\merish5web\node_modules\hidefile\index.js:225:15)
    at EventEmitter.ipcMain.on (C:\Git\merish5web\src\electron-starter.js:234:37)
    at emitTwo (events.js:125:13)
    at EventEmitter.emit (events.js:213:7)

With Mac and Linux this library works fine, but under windows it crash, I also tryed to remove and reinstall the module with no luck.

@PsyKoMari PsyKoMari changed the title hidefile file not found error with folder hidefile file not found error with folder in Windows May 16, 2018
@PsyKoMari
Copy link
Author

I now cloned the repo and runned the test script..
This is the result:

> hidefile@2.0.0 test C:\Git\hidefile
> mocha test/ --bail --reporter spec --check-leaks



  isDotPrefixed()
    √ should be true for prefixed dot
    √ should be false for missing prefixed dot

  isHidden()
    on Unix
      - should be true for prefix-only files
      - should be true for prefix-only folders
    on Windows
      √ should be false for unprefixed-unattributed files (69ms)
      1) should be false for unprefixed-unattributed folders


  3 passing (210ms)
  2 pending
  1 failing

  1) isHidden() on Windows should be false for unprefixed-unattributed folders:
     Uncaught AssertionError: expected [Error: Impossibile trovare il file] to be null
      at test\test.js:95:24
      at index.js:216:4
      at index.js:110:4
      at node_modules\winattr\lib\shell\index.js:139:3
      at ChildProcess.<anonymous> (node_modules\winattr\lib\shell\index.js:110:3)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)



npm ERR! Test failed.  See above for more details.

@stevenvachon
Copy link
Owner

Does it still happen with v3.0.0? If so, what Node.js version?

@nelsonni
Copy link

nelsonni commented Mar 9, 2021

I encountered this same issue today. MacOS works fine, but Windows throws the following error on a call to shouldBeHiddenSync() within a TypeScript project:

hidefile: v3.0.0
Node: v15.11.0
Electron: v11.3.0
OS: Win10 (Build 1909) and MacOS 11.2.2

Uncaught (in promise) TypeError:
Cannot read property 'getAttributesSync' of undefined
        at Object.getSync (index.js:37)
        at index.js:22
        at Object.run (whichLib.js:75)
        at Object.getSync (index.js:22)
        at statSync (index.js:131)
        at shouldBeHiddenSync (index.js:269)

Attempted to use winattr/getSync directly, to see if the issue is only with hidefile. The same error is thrown, so it appears to be an issue with winattr that is bubbling up to hidefile.

(Side note: I created a typings file (*.d.ts) for this project and had it merged into the DefinitelyTyped project in order to use this project within TypeScript, available here: https://www.npmjs.com/package/@types/hidefile)

@crystalfp
Copy link

crystalfp commented Apr 9, 2021

At the moment seems hideSync() works properly on windows 10 (version 20H2) (hidefile v 3.0.0) for a directory like "D:/data/.trashcan".
@nelsonni thanks for the typing file! Much appreciated.

@nelsonni
Copy link

At the moment seems hideSync() works properly on windows 10 (version 20H2) (hidefile v 3.0.0) for a directory like "D:/data/.trashcan".

@crystalfp Does hideSync() work on Win10 when the file doesn't have the "." prefix and only has the "hidden" attribute set? I believe the underlying winattr/getSync behaves different depending on the presence of one or both of these components on Windows systems.

@crystalfp
Copy link

Yes @nelsonni, it works on D:/xxx
This directory is set hidden and moved to D:/.xxx

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

4 participants