• Kai Ninomiya's avatar
    Reland "Implement FileSystem.rmtree for long paths on Windows" · 85686aef
    Kai Ninomiya authored
    This is a reland of 2eb368c0
    
    Changed to not allow long paths for the root of the tree
    being rmtree'd, so it works on Windows 7.
    
    Original change's description:
    > Implement FileSystem.rmtree for long paths on Windows
    >
    > Changes blinkpy filesystem tests to use remove_contents instead of
    > rmtree. remove_contents calls into rmtree, but
    >   (1) retries several times to delete the files, and
    >   (2) throws by default instead of silently swallowing errors.
    > This improves all of the tests. Additionally, the retrying was
    > actually necessary to pass many tests (files were otherwise still
    > locked during teardown).
    >
    > Extends the test_long_paths test to check spaces and apostrophes.
    >
    > FileSystem.rmtree is now implemented on Windows by just calling
    > a shell with "rmdir /s /q". This is necessary, because
    > shutil.rmtree doesn't work for \\?\C:\ style "extended-length" paths
    > on Windows, and several other implementations I tried didn't work:
    >   - Loop using os.walk. os.walk doesn't support long paths, and
    >     though it seemed to work on the bots, it failed tests locally.
    >   - Recursive using os.listdir. os.listdir also doesn't support long
    >     paths.
    >
    > Tested on dawn-win10-* try job on crrev.com/c/2050036/17.
    > Found in dawn-win10-* try jobs on crrev.com/c/2050036/4.
    >
    > Change-Id: I7c67bb12305a41244829e35293edfc88901b76f4
    > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2058065
    > Commit-Queue: Kai Ninomiya <kainino@chromium.org>
    > Reviewed-by: Robert Ma <robertma@chromium.org>
    > Cr-Commit-Position: refs/heads/master@{#742961}
    
    Bug: 1054331
    Change-Id: Ib1f7a7ac0109fb77e1d26f1bdb292ad2c95cea24
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092946
    Commit-Queue: Kai Ninomiya <kainino@chromium.org>
    Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#748886}
    85686aef
filesystem.py 17.4 KB