From 720c6479594a9a703db1de6c3bc2fafa3d20775f Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jul 26 2016 20:20:54 +0000 Subject: just wrap shutil.move for now --- diff --git a/koji/util.py b/koji/util.py index 9a73c82..461ccce 100644 --- a/koji/util.py +++ b/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', '.')):