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

fix #3023 make expandSymlink work on Windows #17289

Closed
wants to merge 10 commits into from

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Mar 7, 2021

fix #3023

followup

  • expandFileName should use GetFinalPathNameByHandleW too.

@ringabout ringabout added the TODO: followup needed remove tag once fixed or tracked elsewhere label Mar 7, 2021
@ringabout ringabout marked this pull request as draft March 7, 2021 14:53
lib/pure/os.nim Outdated Show resolved Hide resolved
@timotheecour
Copy link
Member

timotheecour commented Mar 7, 2021

expandFileName should use GetFinalPathNameByHandleW too.

see bug8 from #16784:

bug8: expandFilename doesn't seems to resolve symlinks (unlike on posix); GetFinalPathNameByHandleA seems like what should be used (but should be called through expandSymlink)

ie, it should instead call expandSymlink once it's fixed

lib/pure/os.nim Outdated Show resolved Hide resolved
lib/pure/os.nim Outdated Show resolved Hide resolved
lib/pure/os.nim Outdated Show resolved Hide resolved
@ringabout ringabout marked this pull request as ready for review March 12, 2021 15:34
lib/pure/os.nim Outdated Show resolved Hide resolved
lib/pure/os.nim Outdated Show resolved Hide resolved
lib/pure/os.nim Outdated Show resolved Hide resolved
lib/pure/os.nim Outdated Show resolved Hide resolved
@ringabout ringabout marked this pull request as draft March 14, 2021 05:06
@ringabout ringabout changed the title fix #3023 fix #3023 make expandSymlink() work on Windows Mar 14, 2021
@ringabout ringabout changed the title fix #3023 make expandSymlink() work on Windows fix #3023 make expandSymlink work on Windows Mar 14, 2021
@ringabout ringabout marked this pull request as ready for review March 14, 2021 08:35
@ringabout ringabout marked this pull request as draft March 14, 2021 08:36
@ringabout ringabout marked this pull request as ready for review March 14, 2021 15:54
@ringabout ringabout closed this Mar 20, 2021
@ringabout ringabout reopened this Mar 20, 2021
Comment on lines +272 to +273
let f = open(symlinkSrc, fmWrite)
f.close()
Copy link
Member

@timotheecour timotheecour Mar 20, 2021

Choose a reason for hiding this comment

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

  • I don't understand this; you're creating a file "D20210101T1920_nonexistant" (nonexistant should indicate it doesn't exist)
  • generated files should go under buildDir (which is gitignored), but symlinkSrc is not

simply use:

const symlinkFile = buildDir/"D20210101T191320_BROKEN_SYMLINK"
const symlinkSrc = "nonexistant"
createSymlink(symlinkSrc, symlinkFile)
doAssert expandSymlink(symlinkFile) == symlinkSrc

Comment on lines +1733 to +1734
if not symlinkExists(symlinkPath):
raise newException(OSError, symlinkPath & " is not symlink or does not exist")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if not symlinkExists(symlinkPath):
raise newException(OSError, symlinkPath & " is not symlink or does not exist")

because it's redundant with the check a few lines below:

if handle == INVALID_HANDLE_VALUE:
  raiseOSError(osLastError(), symlinkPath)

unless i'm missing something

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
@ringabout ringabout closed this Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO: followup needed remove tag once fixed or tracked elsewhere
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please make expandSymlink() work in Windows!
4 participants