Fix ability to use add-track force on symlink tracks #1966
Merged
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.
Possible fix for #1958
The main thing is that it needs to unlink the destination before trying to symlink it
It is somewhat of a coincidence that copy behavior is to overwrite by default. I changed it to actually use COPYFILE_EXCL to avoid accidentally overwriting a destination file, and the user can go back and use --force to overwrite it, which matches the behavior of overwriting the symlink added in this PR
It uses a try catch because if the destination symlink doesn't exist it would otherwise throw
Adds some misc refactoring (could be split out) to try to simplify or deduplicate some repetitive logic in the code and tests with the hope that simpler code==easier to see code paths
https://github.com/GMOD/jbrowse-components/compare/fix_symlink_add_track?expand=1#diff-7c20288c5391381db2117575ccf46defd61fd768480ee3af4cc60d2fe1bbde21R315-R318