Skip to content

Conversation

@mitchell-as
Copy link
Collaborator

@mitchell-as mitchell-as commented Nov 19, 2024

StoryDX-3167 Our depot linking mechanic is aware of directories it has already traversed

@mitchell-as mitchell-as requested a review from Naatan November 19, 2024 19:36
@mitchell-as mitchell-as marked this pull request as ready for review November 19, 2024 19:36
This results in a destination without directory links, which are not supported on Windows.
@mitchell-as mitchell-as requested a review from Naatan November 21, 2024 18:57
Copy link
Contributor

@Naatan Naatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitchell-as mitchell-as requested a review from Naatan November 21, 2024 20:16
Copy link
Contributor

@Naatan Naatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitchell-as mitchell-as requested a review from Naatan November 22, 2024 00:35
if visited == nil {
visited = make(map[string]bool)
}
if _, exists := visited[src]; exists && srcWasSymlink {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think this is now trying to solve the same issue two ways. If the src is a symlink then we should just make the deployment a link also, and stop iterating further down because it's a symlink. In this case what we already visited is irrelevant.

So I think we can get rid of the visited logic altogether, and simply revise it to make dir links if the src is a dir link, and otherwise create the dir and continue recursion.

@mitchell-as
Copy link
Collaborator Author

I am a bit nervous about these changes, as I don't know if they'll have unintended consequences. The critical tests seem to be passing, so that brings a little comfort.

@mitchell-as mitchell-as requested a review from Naatan November 22, 2024 23:09
@mitchell-as
Copy link
Collaborator Author

@Naatan ping

}

if fileutils.IsDir(src) {
if isSymlink(src) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isSymlink(src) {
if fileutils.IsSymlink(src) {

Comment on lines 141 to 145
func isSymlink(src string) bool {
target, err := fileutils.SymlinkTarget(src)
return err == nil && src != target
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func isSymlink(src string) bool {
target, err := fileutils.SymlinkTarget(src)
return err == nil && src != target
}

src != target does not assert whether something is a symlink. Is this a concern we have? We could add the error check and return an error, but this doesn't feel relevant to the issue at hand. ie. the bug we're addressing isn't that a file is linking to itself.

Comment on lines 150 to 154
src, err = filepath.Abs(filepath.Clean(src))
if err != nil {
return "", "", errs.Wrap(err, "Could not resolve src path")
}
dest, err = fileutils.ResolveUniquePath(dest)
dest, err = filepath.Abs(filepath.Clean(dest))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert. Absolute path does not give a canonical result, whereas ResolveUniquePath does (or at least -tries to-).

@mitchell-as mitchell-as reopened this Nov 27, 2024
@mitchell-as mitchell-as merged commit 6054081 into version/0-47-0-RC1 Nov 27, 2024
14 of 15 checks passed
@mitchell-as mitchell-as deleted the mitchell/dx-3167-2 branch November 27, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet