镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Provide a way to create clone/CoW copies #12902

Description

@candrews

Currently, copying files is implemented by reading the data of the source file and writing it to the new file, see fs-extra's implementation of copy. The problem is that this approach doesn't allow the OS to optimize file copying (such as by using direct disk-to-disk copy if it's available), nor does it allow the (optional or by default) use of reflink/CoW.

I'm specifically interested in making CoW (which is already available on some *nix file systems, including btrfs and zfs) available to nodejs.

IMHO, nodejs should add an fs.copy function (just like what fs-extra already does) which is implemented using the OS native file copying syscall. It should have an optional option parameter that allows specifying the copy should use CoW (if available), just like how cp --reflink=auto from coreutils works on Linux.

Note that this would be particularly benefit for cases where files are copied often - particularly big files. I'm thinking that this improvement would substantially benefit package managers (npm, yarn, etc).

Activity

  1. added
    feature requestIssues requesting new Node.js features.
    fsIssues and PRs related to file-system APIs and the fs module.
    on May 8, 2017
  2. eljefedelrodeodeljefe commented on May 9, 2017

    @eljefedelrodeodeljefe
    Contributor

    Likely needs libuv implementation. Related: libuv/libuv#925

  3. Daniel15 commented on Jun 6, 2017

    @Daniel15

    Also see some of the attempts at using native copy calls in Yarn:

    yarnpkg/yarn#3290 which uses https://github.com/sciolist/fcopy (Unix via a native module)
    yarnpkg/yarn#2960 (Win32 via node-ffi)

  4. richardlau commented on Sep 8, 2017

    @richardlau
    Member

    fs.copyFile was added by #15034.

  5. cjihrig commented on Sep 8, 2017

    @cjihrig
    Contributor

    FWIW, CoW is not supported yet. There is a PR to add it to libuv but I haven't landed it yet because I have yet to see it work on any of the CI machines.

  6. richardlau commented on Sep 8, 2017

    @richardlau
    Member

    Let's keep this open then.

  7. coderaiser commented on Sep 13, 2017

    @coderaiser
    Contributor

    Ponyfill fs-copy-file can be used for copying files. In node.js < v8.5.0 it copies files with help of streams and for v8.5.0 and next versions it uses native implementation of fs.copyFile.

  8. Daniel15 commented on Oct 4, 2017

    @Daniel15

    @coderaiser - That looks like a useful module. Although, technically that's not a ponyfill as ponyfills never use the native API (as per the document you linked to) 😃

  9. cjihrig commented on Apr 6, 2018

    @cjihrig
    Contributor

    Forgot to link it, but this is closed in a16d88d.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions