Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

install: Update fs.access to allow io.js versions w/ fixed windows ver #9038

Closed
wants to merge 1 commit into from

Conversation

iarna
Copy link
Contributor

@iarna iarna commented Jul 23, 2015

This also pushes them off to their own file, so we can stop doing
the copy-pasta dance. It also makes explaining the rational of the
check cleaner I think.

@iarna iarna added this to the 3.x-next milestone Jul 23, 2015
@@ -2,17 +2,9 @@
var fs = require('fs')
var inflight = require('inflight')
var accessError = require('./access-error.js')
var isFsAccessAvailable = require('./is-fs-access-avalable.js')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avalable should have been available?

@iarna iarna force-pushed the iarna/allow-fs-access-in-new-iojs-on-win branch from b773b5d to 4ac2a1e Compare July 23, 2015 10:37
@iarna iarna force-pushed the iarna/allow-fs-access-in-new-iojs-on-win branch from 4ac2a1e to 7c1674f Compare July 23, 2015 10:38
This also pushes them off to their own file, so we can stop doing
the copy-pasta dance. It also makes explaining the rational of the
check cleaner I think.

PR-URL: #9038
@iarna iarna force-pushed the iarna/allow-fs-access-in-new-iojs-on-win branch from 7c1674f to 25d4906 Compare July 23, 2015 11:42
@zkat
Copy link
Contributor

zkat commented Jul 23, 2015

🐑

module.exports = true
} else {
// The Windows implementation of `fs.access` has a bug where it will
// sometimes return access errors all the time for directories, even
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes returns ... all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under some circumstance that I don't understand, it always claims directories to be unwritable. These circumstances don't show up all the time, but when they do, they always result in failures.

At least, that was how I understood someone else's explanation of the bug. TBH, I haven't read the source material enough to summarize it directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. We can leave it as it is then.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under some circumstance that I don't understand, it always claims directories to be unwritable. These circumstances don't show up all the time, but when they do, they always result in failures.

from trial and error: if directories would require admin access they are reported as unwritable even if running as admin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it matter that the fix in io. js was to always return true in windows for directories?
Are you just relying on someone adding functionality to fs.access? what happens if it doesnt detect access.. will npm not roll back correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukeapage
If fs.access is just blindly returning true on Windows, then yes, that is a problem. I'm going to have to go digging through the libuv source, clearly.

The only problem with the permissions checks being too permissive, is that you get failures later rather than earlier. It shouldn't otherwise cause issues, but I'd still like to fix it. My fallback code just tries making a file in the directory to see if it has permission, and perhaps we'll have to permanently use that.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be much appreciated, but I don't see any links?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I dug up the source, and yeah, I see it. Blerg. Ok, I guess I'll just ditch using access entirely.

@thefourtheye
Copy link
Contributor

LGTM with a nit

@@ -0,0 +1,24 @@
'use strict'
var fs = require('fs')
var process = require('process')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary.

Edit: Ah, I think this is how the version is injected in the tests. Nvm then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. I didn't even know I could require process until I went to write these tests =D

@thefourtheye
Copy link
Contributor

Thanks. Learned a lot from this PR. LGTM, if that matters :)

iarna added a commit that referenced this pull request Jul 24, 2015
This also pushes them off to their own file, so we can stop doing
the copy-pasta dance. It also makes explaining the rational of the
check cleaner I think.

PR-URL: #9038
iarna added a commit that referenced this pull request Jul 25, 2015
This also pushes them off to their own file, so we can stop doing
the copy-pasta dance. It also makes explaining the rational of the
check cleaner I think.

PR-URL: #9038
@sindresorhus
Copy link

@iarna
Copy link
Contributor Author

iarna commented Jul 25, 2015

@sindresorhus You're just stating and checking the results there? Is that actually all the underlying mechanism does? I guess I should go look at libuv... =D If that's all its doing then it probably isn't doing what I want anyway.

My main concern is that there are a lot of other, OS specific, ways of making a directory unwritable that can't be sussed from unix-style permissions. My fallback approach is to actually try to make a file and see if that works, which I guess is the duck-typing of folder permission checking. If fs.access really is just a user friendly way of looking at the results of stat then I'll have to rethink my use of it.

@iarna
Copy link
Contributor Author

iarna commented Jul 25, 2015

Thanks for the critical eye here @thefourtheye – This landed as 28ebc6c with some changes, as it turns out you can only require('process') on io.js. =D

I was able to instrument things in a different way for node 0.12 and io.js, but 0.10 eluded me and ultimately I ended up making the test skip on that target. =/

@iarna iarna closed this Jul 25, 2015
@iarna iarna removed the in-progress label Jul 25, 2015
@iarna iarna deleted the iarna/allow-fs-access-in-new-iojs-on-win branch July 27, 2015 19:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants