Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the symlink creation #225

Merged
merged 3 commits into from
Sep 14, 2021
Merged

Conversation

ForestEckhardt
Copy link
Contributor

@ForestEckhardt ForestEckhardt commented Sep 8, 2021

Attempts to get rid of sorting and make the algorithm more graph like. This will hopefully make the algorithm more robust by removing the significance of ordering of the files.

Resolves #224

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

- Build a quasi-graph using a map that can be traversed and create
symlinks that are not dependent on other symlinks
@ForestEckhardt ForestEckhardt force-pushed the symlink-creation-algorithm-change branch from 290a644 to b6d49d2 Compare September 9, 2021 14:34
@ForestEckhardt ForestEckhardt marked this pull request as ready for review September 9, 2021 14:34
@ForestEckhardt ForestEckhardt requested a review from a team as a code owner September 9, 2021 14:34
@ForestEckhardt
Copy link
Contributor Author

@paketo-buildpacks/tooling-maintainers I only have two question for code review.

  1. Should I refactor symlink writing into its own function to remove the duplicate code from the tar and zip archive files?
  2. Should I put in some safeguarding against a cyclical symlink situation? And if so what would you suggest for a safeguard strategy?

@ryanmoran
Copy link
Member

  1. yes. maybe separate the sorting from the symlink creation in the process
  2. you can write the loop so that you attempt to make 1 link each time around the outer loop. here is what I was thinking
maxIterations := len(symlinkMap)
for i := 0; i < maxIterations; i++ {
  for path, linkname := range symlinkMap {
    if shouldSkipLink {
      continue
    }

    // make the link
    delete(symlinkMap, path)
    break
  }
}

if len(symlinkMap) > 0 {
  return errors.New("this symlink graph contains a cycle!")
}

@ForestEckhardt
Copy link
Contributor Author

@ryanmoran Great. I will ping you when I have finished up those changes

@ForestEckhardt
Copy link
Contributor Author

@ryanmoran I added to logic to both remove the potential for deadlock as well as removing the label. I didn't quite grock what you wanted in terms of extracting the functionality so I left it in place for the time being.

@ryanmoran
Copy link
Member

@ForestEckhardt here is what I was thinking: e298983

@ForestEckhardt
Copy link
Contributor Author

@ryanmoran Honestly that refactor works for me! If that is all good on your end then we can just merge.

@ryanmoran ryanmoran merged commit 9dbcc2e into main Sep 14, 2021
@ryanmoran ryanmoran deleted the symlink-creation-algorithm-change branch September 14, 2021 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error evaluating symlinks during tgz extraction
2 participants