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 "archive" option (cp -a) #522

Closed
aikar opened this issue Nov 30, 2017 · 8 comments
Closed

copy "archive" option (cp -a) #522

aikar opened this issue Nov 30, 2017 · 8 comments

Comments

@aikar
Copy link

aikar commented Nov 30, 2017

It would be nice if an archive option for copy was provided to mimic -a on cp, to copy a file/directory exactly as it was in the source.

at least primarily, file owner and file permissions

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 30, 2017

We already preserve permissions by default, and we have a preserveTimestamps option for preserving timestamps.

Not particularly clear on how file ownership works in Node.js, maybe the rest of the team knows more? @jprichardson @manidlou

@aikar
Copy link
Author

aikar commented Dec 1, 2017

it would be something to worry about when ran with sudo/root, to avoid the file being owned by root, to keep original owner.

https://nodejs.org/api/fs.html#fs_fs_chown_path_uid_gid_callback

@RyanZim
Copy link
Collaborator

RyanZim commented Dec 11, 2017

Given that I haven't heard anything from the rest of the team, I'm gonna say PR welcome. @aikar You want to try this?

@manidlou
Copy link
Collaborator

manidlou commented Feb 6, 2020

Yeah as @RyanZim said, we already have preserveTimestamps option and we set the file permissions (mode) through fs.chmod() after the copy is completed by default. But currently we don't do anything for ownership.

According to cp man page, cp -a means preserve=all which is preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all.

@manidlou
Copy link
Collaborator

manidlou commented Feb 6, 2020

So the question is do we want to set the file ownership by default like what we currently do for mode or we wanna make it optional like preserveTimestamps?

@manidlou
Copy link
Collaborator

@jprichardson @RyanZim @JPeer264 ?^

@RyanZim
Copy link
Collaborator

RyanZim commented May 11, 2020

IMO, our default behavior should match fs.copyFile, and any deviation from that should be an option, if supported.

I am a bit curious how frequently you'd be running as root though; which is the primary reason you'd want this feature.

@RyanZim
Copy link
Collaborator

RyanZim commented Sep 21, 2021

As per #912; fs.cp is coming to Node core, and options there will be dictating our feature set, so closing as wontfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants