201
202
:param old: The old path, to rename from
202
203
:param new: The new path, to rename to
203
204
:param rename_func: The potentially non-atomic rename function
207
208
# sftp rename doesn't allow overwriting, so play tricks:
208
209
base = os.path.basename(new)
209
210
dirname = os.path.dirname(new)
210
tmp_name = u'tmp.%s.%.9f.%d.%s' % (base, time.time(), os.getpid(), rand_chars(10))
211
216
tmp_name = pathjoin(dirname, tmp_name)
213
218
# Rename the file out of the way, but keep track if it didn't exist