-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
[fix] futimes
only works for owned files with write access
#128
Conversation
@piranna I think we need to |
Are you talking about doing the ownership check first instead of capturing
|
Just a note: keep in mind that more fs calls = way slower. dest was only 1 fs call - now it seems to be ballooning to add new features. Performant and minimal should be the default, features should be enabled as needed. |
src has a lot of calls to fs methods, so I don't think dest will be our bottleneck. However, maybe we need to consider making things like these extra methods on the vinyl-fs adapter. e.g. - |
Long-term idea: what about make dest to know when we are trying to create a
|
@phated yeah, i'm more in favor of alternate functions (vs. cramming everything into dest) |
I've updated the pull-request to check if we are the owners of the file instead of capturing the |
@phated What would be the advantage of doing up to two filesystem calls ( @contra I understand the argument to keep things like |
Maybe it could be used a flag to set if instead throw an error as now happens, swallow it and update the vinyl object with the content from the filesystem, this way we don't break current functionality but also allow to give an oportunity to that methods that require higher priviledges. |
@piranna I think this feature needs to be behind an option flag or in a separate method. |
Are you talking about the swallow of errors of priviledged methods like chmod or futimes and update of the vinyl object, isn't it? I agree on the swallow of the errors as a flag, but maybe the update of the vinyl object should have its own flag, isn't it? Do you want I implement it? |
I suppose that `vfs.touch()``would apply all this priviledged functionality at once (uid, gid, utimes, mode...), isn't it? |
@piranna no, touch would be equivalent to https://en.wikipedia.org/wiki/Touch_(Unix) (doesn't modify uid, guid, modes) |
Do you propose then to have one method for each of the entries? I would prefer a |
I think that could be beneficial but I don't like the idea of calling it Also, having a singular method for those would make the implementation very complex. I've always viewed the vinyl adapter spec as having 2 methods (src & dest), especially now that we removed watch. However, we also have added symlink to vinyl-fs but that method doesn't make sense for other transports (such as vinyl-http). Maybe symlink, touch, chmod, etc are outgrowing the base spec and could become an addon library. Thoughts? /cc @contra |
^ the addon library could still be included with gulp 4 |
I though first about
Not really, they could be done easily and in a generic way with try-catch, for example. |
@phated @piranna But because of the sub-second quirk we ran into earlier, these would actually be working with file descriptors and wind up calling I'd also like to see a |
Fair for me.
Interesting... I think this is a good point about having that functionality integrated on
Yeah, because it's already done by |
Fair enough, I guess I had that coming -- of course I am again talking about the case where But maybe the consensus is actually that if these attributes like times etc matter especially then you should just make a distinct pipeline starting with another |
It makes sense, and it would be simpler... |
Here are the viable options as I see them:
I don't think exposing new functions for different attributes is good API design on this one. |
Maybe this is a completely inaccurate projection of long-ago C intuition, but once you have a file descriptor to an open file, which you can safely re-use within The hit would have to be pretty horrible for users to accept an awkward default behaviour of |
@erikkemperman Only way to know for sure is to make some benchmarks |
+1
+1000 |
I'm fine with all of @contra's proposals. However, changing this now that there was a release (due to being an added feature) is a breaking change, so we need it so we need it solved ASAP. This seems to be the last blocking thing on gulp 4 |
Looking at this yesterday I noticed that there is already a So I think it would be cleaner to handle these attributes in one place, but passing file descriptors around is a bit messy because that doesn't work for I also noticed that the logic around I don't see it yet but assume there's a good reason for that. There's even a test to check that |
@piranna will you have a chance to rebase this soon? |
Going to put a time limit of a few more days on these stat changes - if we aren't able to get the fixes merged soon I'm going to revert the broken changes that were merged earlier since it is holding up a release. |
@contra while I agree that it is annoyingly holding up a release, I don't know if removing the functionality to push a release out quicker is the best idea. It would require bumping vinyl-fs a major version since we are removing functionality that was added in a minor and then I would only feel comfortable adding it back in a major since it caused all these troubles, which means it will never land in gulp 4. This feature surfaced a big problem with vinyl and vinyl-fs - the fact that they only deal with a tiny subset of file properties (path and contents) but it is advertised as an in-memory, streaming file system abstraction. If we aren't handling other metadata correctly and aren't able to update that metadata on the actual filesystem, people are going to reach for the |
@phated Was this ever released on npm in a way that people could use? If not I think we can revert this without causing any harm. |
@contra yeah, unfortunately the utimes stuff was released in 2.2.0. 2.2.1 was a fix for trying to write invalid dates, 2.3.0 now has a fix for sub-second precision and these changes are to fix a bug where the utimes call fails if the process user isn't the file owner. We also need to finish gulpjs/vinyl#72 (which @erikkemperman started on) because we actually read the stats of every file and attach them while looking for symlinks (we didn't do that before 2.x) We found all these issues because people are using it with the gulp 4.0 branch and have been reporting the problems. |
Sorry for the delay, I have been busy lately and the rebase is giving me a lot of problems to make the tests to pass.
It seems the module fstream from the npm developers is getting some traction (I didn't knew of it until some weeks ago and now I'm seeing it's a dependency of almost all the projects I'm using lately...) and has support for streaming directories and symlinks, maybe we could get some inspiration from it... |
I can't be able to fully fix the problems that has surfaced after the rebase, seems it's getting some problems due to the usage of the file descriptors... Don't know if the library to manage them would help, but the more I think about it, the more I believe we've gone too far optimizing by using them instead of using plain old path based operations just to have sub-second precission... Does it matter so much? Also, other problems are related with symlinks and the fact they are not used as first class citizens here... :-/ |
Sorry I'm a little late to the show, but what issue are the symlinks posing? I might be of some assistance. |
I attempted the rebase of this stuff as well, and couldn't figure it out either. Didn't spend a lot of time on it though, but my feeling from its description was this library from rvagg might help. Personally I feel that sub-second precision is rather a big deal. That is, if we want things like |
As I remember, since some filesystems don't support symlinks (mostly FAT) |
@contra @phated @piranna @Klowner So I spent a little more time with the rebased work and got all tests to pass. Yay! See the code here and the test results here. I've taken the liberty of squashing the very many commits, I hope you don't mind... I guess it should still be tidied up a bit with some flow-control library, like we talked about earlier. More importantly, it currently skips writing metadata for symlinks, just like it did before... I propose discussing that in a different issue if anyone has ideas. |
nice job, @erikkeperman! That seems good to me from what I can tell. |
All this commits will be lost as tears in the rain... :-P It hurts my ego, but I admit they needed some clean-up.
It's ok to discuss this on a different issue, but I think this should be fixed too, that's important to set them correctly and not merge the stats of the symlink and the destination file.. |
How appropriate, it was his birthday last Friday 👍 Seriously though, we can obviously package this however you like -- to use a football phrase, I just walked into a header from an excellent pass. To reflect this you might consider adding my fork as a remote, and force-pushing it into your branch for this PR? Feel free to squash as you see fit :-) Like I said it probably still needs some work, for one thing I really don't like that descriptors and streams are opened and closed/ended in different modules now. Maybe the Come to think of it, that might even make things sufficiently separated to leave out further flow-control. |
I think I made it slightly more legible... But that's subjective of course. Will leave it for now, let me know how you want to proceed! |
@erikkemperman you are my hero today. Can you squash your commits so there's just 2 commits (1 squashed @piranna commit and 1 squashed commit for you) and then submit a PR? |
I was not thinking about that fact, just I love that movie :-D
That's because close of file descriptors is common, probably the same could be done with open. |
You are welcome :-) 2016-02-26 2:19 GMT+01:00 Blaine Bublitz notifications@github.com:
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un monton |
This fixes issue #127