Skip to content

Question about copy logic #1067

@RyanZim

Description

@RyanZim

@manidlou Looking at the code, I'm not sure I understand the meaning of the comment here:

// dest exists and is a regular file or directory,
// Windows may throw UNKNOWN error. If dest already exists,
// fs throws error anyway, so no need to guard against it here.
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)

Is the intent that if dest exists, but can't be read, we call fs.symlinkSync in order to trigger an EEXIST error here? Assumption being that if we can't read it, we can't unlink it either?

Basically, I'm trying to make sure that it's intentional that we're just symlinking without unlinking first in this case here. LMK if there's anything I can clarify.

The same comment & logic exists in copy() as well:

// dest exists and is a regular file or directory,
// Windows may throw UNKNOWN error. If dest already exists,
// fs throws error anyway, so no need to guard against it here.
if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions