Skip to content

FileState/Copy task support for symlinks #703

Open

Description

@rainersigwald

The Copy task currently uses a FileState which is a wrapper around a WIN32_FILE_ATTRIBUTE_DATA. That allows it to populate timestamps + file size with a single syscall, but if the input is a symlink, the data will be for the symlink, not its target. That means that additional work may be done in a <Copy SkipUnchangedFiles="true" /> invocation, because the timestamp of the copy destination from last time will match the symlink target, not the symlink itself.

This is not a terrible problem, because Copy doesn't behave incrementally based on timestamps (like target execution). It uses timestamp + file size as a proxy for identicality. If it looks at a symlink, the timestamp and file size will differ, so the copy will happen. Since the copy destination's timestamp will match the source file's after the copy, this won't cause a rebuild cascade, because anything downstream that consumes the copied file will see the correct timestamp.

It's tempting to say that we could just call GetFileInformationByHandle instead of GetFileAttributesEx, but BY_HANDLE_FILE_INFORMATION doesn't have a size field, so that doesn't get us the full set of data we'd want.

Activity

  1. rainersigwald commented on Jun 16, 2016

    @rainersigwald
    MemberAuthor

    More details in #322 (comment)

  2. chamons commented on Nov 26, 2018

    @chamons

    I've worked around this by shelling out to cp -r on macOS.

  3. added
    Area: Tasks
    on Dec 12, 2018
  4. Forgind commented on Jun 8, 2022

    @Forgind
    Contributor

    If you use a glob with ** somewhere that references a symlink, we follow that symlink. If that symlink points to a directory above itself, we check all the directories under that, including the same symlink and follow it again and again. I put a fix into FileMatcher.GetFilesRecursive in #7685 that uses an API only introduced in NET6.0, so it's imperfect. It also needs to avoid impairing performance, as that's a very common code path. As a compromise, I didn't address a few cases, as noted in the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Taskssymlinktriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions