Skip to content

handle copying between identical files #198

@chinesedfan

Description

@chinesedfan

I hope this module can be as clever as cp. It should recognize copying between identical files and do nothing.

Now, v0.26.2, neither copy nor copySync can handle these cases correctly.

  • If src and dst are the same file
    • It opens a read stream first, and then a write stream, which results in the file becomes empty.
  • If src is symbolic link and points to dst
    • By default, option clobber is true, so that dst will be removed, which means the real file is removed. If clobber is false, the file becomes empty.
  • If dst is symbolic link and points to src
    • Similar to the previous case, dst is removed and a new file is created, then the link is not existed any more. Or the file becomes empty.

I have added corresponding test cases in my branch.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions