Message106601
| Author |
vstinner |
| Recipients |
giampaolo.rodola, tarek, vstinner |
| Date |
2010年05月27日.09:58:53 |
| SpamBayes Score |
0.025128856 |
| Marked as misclassified |
No |
| Message-id |
<1274954336.17.0.28560552817.issue8828@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Begin by removing the dest file is maybe not the safer approach :-) Here is a new try: begin by renaming the dest file to a new file.
------
# use maybe a PRNG instead of a dummy counter or tempfile
def _create_old_filename(filename):
old = filename + '.old'
index = 2
while os.path.exists(old):
old = filename + '-%s.old' % index
index += 1
return old
if os.name in ('nt', 'ce'):
def atomic_rename(src, dst):
if os.path.exists(dst):
old = _create_old_filename(dst)
rename(dst, old)
rename(src, dst)
unlink(old)
else:
rename(src, dst)
else:
atomic_rename = os.rename
------
What can we do if "rename(src, dst)" fails? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年05月27日 09:58:56 | vstinner | set | recipients:
+ vstinner, giampaolo.rodola, tarek |
| 2010年05月27日 09:58:56 | vstinner | set | messageid: <1274954336.17.0.28560552817.issue8828@psf.upfronthosting.co.za> |
| 2010年05月27日 09:58:53 | vstinner | link | issue8828 messages |
| 2010年05月27日 09:58:53 | vstinner | create |
|