Repository navigation
fix(io): honor no-overwrite when copying symlinks - #2588
Open
pradeep-ramola wants to merge 1 commit into
Open
pradeep-ramola wants to merge 1 commit into
pradeep-ramola wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Honor
force: falsewhen recursivecp()copies a symbolic link over an existing destination entry.The symlink branch in
copyFilecurrently unlinks the destination without checkingforce. For a recursive copy, an existing regular file can therefore be deleted and replaced with a symlink even though the caller explicitly disabled overwriting. Existing symlinks, including dangling ones, are replaced too.Check
forceafter the existinglstatsucceeds and before unlinking. Usinglstathere preserves dangling destination links as well as valid ones. The overwrite-enabled and missing-destination paths retain their existing behavior.Regression coverage
Six filesystem cases cover regular files, valid symlinks, and dangling symlinks with
forceboth enabled and disabled. They check preserved file contents or link targets, successful replacement when forced, and preservation of the original link target's contents. On Windows the tests use the existing junction helper, so they do not require elevated symlink permissions.Before the production change, all three
force: falsecases failed and the threeforce: truecontrols passed.Validation
npm test -- --runInBand packages/io/__tests__(62 tests passed)npm run tsc --prefix packages/ionpx eslint packages/io/src/io.ts packages/io/__tests__/io.test.tsnpx prettier --check packages/io/src/io.ts packages/io/__tests__/io.test.tsgit diff --checkValidated locally on Windows. AI assistance was used to develop and validate this change.