just wrap shutil.move for now

This commit is contained in:
Mike McLean 2016-06-10 14:47:47 -04:00
parent 03c3be7125
commit 720c647959

View file

@ -318,10 +318,20 @@ def rmtree(path):
os.rmdir(dirpath)
def safe_move(src, dst):
"""Wrapper around shutil.move with additional safety"""
def safer_move(src, dst):
"""Rename if possible, copy+rm otherwise
pass
Behavior is similar to shutil.move
Unlike move, src is /always/ moved from src to dst. If dst is an existing
directory, then an error is raised.
"""
if os.path.exists(dst):
raise koji.GenericError, "Destination exists: %s" % dst
elif os.path.islink(dst):
raise koji.GenericError, "Destination is a symlink: %s" % dst
# TODO - use locking to do a better job of catching races
shutil.move(src, dst)
def _relpath(path, start=getattr(os.path, 'curdir', '.')):