[Fedora-livecd-list] [PATCH] changed code to try to use os.rename first then shutil.move when moving around the images files. If the file are on the same fs will be alot faster. If not the rename fails and it reverts to shutil.move
Jeremy Katz
katzj at redhat.com
Tue Oct 14 16:37:54 UTC 2008
First, can you please follow good practice and use a short (<= 80,
preferably 72) characters for the first line of your commits and then
put the longer version? This makes things look a lot better in gitweb,
git log, git shortlog, etc....
Also, shutil.move already does this so it really shouldn't be needed
here as well
def move(src, dst):
"""Recursively move a file or directory to another location.
If the destination is on our current filesystem, then simply use
rename. Otherwise, copy src to the dst and then remove src.
A lot more could be done here... A look at a mv.c shows a lot of
the issues this implementation glosses over.
"""
try:
os.rename(src, dst)
except OSError:
if os.path.isdir(src):
if destinsrc(src, dst):
raise Error, "Cannot move a directory '%s' into itself
'%s'." %
(src, dst)
copytree(src, dst, symlinks=True)
rmtree(src)
else:
copy2(src,dst)
os.unlink(src)
Jeremy
More information about the Fedora-livecd-list
mailing list