just wrap shutil.move for now
This commit is contained in:
parent
03c3be7125
commit
720c647959
1 changed files with 13 additions and 3 deletions
16
koji/util.py
16
koji/util.py
|
|
@ -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', '.')):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue