Switch from os.rename to shutil.move to support cross-fs renames when needed.

Review Request #1157 - Created Oct. 14, 2014 and submitted

Information
John Sirois
pants
jsirois/rename/safe
671
5f41ffc...
Reviewers
pants-reviews
areitz, benjyw

In each of these cases dst is a file or a new dir. In these 2 cases the ouput of os.rename and shutil.move are identical (they are only different when dst is an existing dir).

src/python/pants/backend/core/tasks/clean.py | 3 ++-
src/python/pants/backend/python/commands/setup_py.py | 7 ++++---
src/python/pants/binary_util.py | 3 ++-
src/python/pants/cache/local_artifact_cache.py | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)

CI went green here: https://travis-ci.org/pantsbuild/pants/builds/38112860

Issues

  • 1
  • 0
  • 0
  • 1
Description From Last Updated
Note that we sacrifice atomicity here. We should probably have an atomic_move helper that does a shutil.move into a temporary ... Patrick Lawson Patrick Lawson
John Sirois
Andy Reitz
John Sirois
John Sirois
John Sirois
John Sirois
John Sirois
John Sirois
John Sirois
Andy Reitz
David Turner
Benjy Weinberger
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Patrick Lawson

   

Note that we sacrifice atomicity here. We should probably have an atomic_move helper that does a shutil.move into a temporary directory alongside the destination directory, then a final atomic os.rename to the destination name.

Loading...