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

copy does not preserve file ownership and permissons #54

Closed
cadorn opened this issue Mar 29, 2014 · 10 comments
Closed

copy does not preserve file ownership and permissons #54

cadorn opened this issue Mar 29, 2014 · 10 comments
Milestone

Comments

@cadorn
Copy link

cadorn commented Mar 29, 2014

No description provided.

@jprichardson
Copy link
Owner

Thanks, I will take a look at this on Tuesday or Wednesday.

@jprichardson
Copy link
Owner

I'm wondering if it may be an issue with the module ncp... AvianFlu/ncp#38 for reference.

@NicolaOrritos
Copy link

Hi there.
I found that this issue is not caused by ncp for a certain number of use-cases.
I think that it's not ncp's fault when using fs.copySync(), but I couldn't come up with a test for demonstrating this, though :-(

Nonetheless I came up with a tentative fix.
The fix revolves around propagating the fs.Stats.mode from lib/copy.js to lib/create.js. File stats are to be read within copy.copySync() and then propagated to create.createFileSync().
This one solved the problem for me.

I'll try to write a pull request as well as a test as soon as possible.

@NicolaOrritos
Copy link

Oops. I forked it and applied my changes, but it fails the test fs-extra + copySync() > when the source is a directory should should apply filter recursively.

@jprichardson
Copy link
Owner

Yeah, ncp isn't used for synchronous copy. There is still an active issue with ncp: AvianFlu/ncp#38

@NicolaOrritos
Copy link

Any idea why that test is failing? I couldn't understand why my changes triggered an issue with filters.

@jprichardson
Copy link
Owner

@NicolaOrritos It's not clear to me what issue you're having. The test passes fine. If your issue is different than this one, please open a new issue with a detailed instructions on how to reproduce the error that you're receiving.

Thank you.

@jprichardson
Copy link
Owner

One step closer: 082aa7f Preserving modes is fixed.

@jprichardson jprichardson modified the milestone: 1.0 Jul 9, 2015
@jprichardson
Copy link
Owner

@H8to
Copy link

H8to commented Dec 22, 2018

@jprichardson
Hi there, sorry to bump an old issue. I'm trying to find the root cause why Atom text editor, which is using node-fs-extra to copy/duplicate directories, does not preserve the permissions.
This is the issue I'm referring to: tree-view #1218

I gave my best to get an understanding of what happens during the copy-job but phew..
As pentester I do not have deep understanding of programming coffee-script, js or similar.

if (initialPathIsDirectory) {
              results.push(catchAndShowFileErrors((function(_this) {
                return function() {
                  fs.copySync(initialPath, newPath);
                  return _this.emitter.emit('entry-copied', {
                    initialPath: initialPath,
                    newPath: newPath
                  });
                };
              })(this)));

from /usr/lib/atom/node_modules/tree-view/lib/tree-view.js

They seem to use the fs.copySync function which should preserve the permissions as per the changelogs of node-fs-extra:

0.11.1 / 2014-09-02
-------------------
- bugfix `copySync()` preserve file permissions [#80][#80]

Atom makers and I would be thankful for any help!

ovr pushed a commit to ovr/node-fs-extra that referenced this issue Nov 12, 2020
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 7.0.2 to 8.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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