Show More
@@ -1457,24 +1457,23 b' def checknlink(testfile):' | |||||
1457 |
|
1457 | |||
1458 | # testfile may be open, so we need a separate file for checking to |
|
1458 | # testfile may be open, so we need a separate file for checking to | |
1459 | # work around issue2543 (or testfile may get lost on Samba shares) |
|
1459 | # work around issue2543 (or testfile may get lost on Samba shares) | |
1460 |
f1, f2, f |
|
1460 | f1, f2, fp = None, None, None | |
1461 | try: |
|
1461 | try: | |
1462 | fd, f1 = tempfile.mkstemp(prefix='.%s-' % os.path.basename(testfile), |
|
1462 | fd, f1 = tempfile.mkstemp(prefix='.%s-' % os.path.basename(testfile), | |
1463 | suffix='1~', dir=os.path.dirname(testfile)) |
|
1463 | suffix='1~', dir=os.path.dirname(testfile)) | |
1464 | os.close(fd) |
|
1464 | os.close(fd) | |
1465 | fd = None |
|
|||
1466 | f2 = '%s2~' % f1[:-2] |
|
1465 | f2 = '%s2~' % f1[:-2] | |
1467 |
|
1466 | |||
1468 | oslink(f1, f2) |
|
1467 | oslink(f1, f2) | |
1469 | # nlinks() may behave differently for files on Windows shares if |
|
1468 | # nlinks() may behave differently for files on Windows shares if | |
1470 | # the file is open. |
|
1469 | # the file is open. | |
1471 |
f |
|
1470 | fp = posixfile(f2) | |
1472 | return nlinks(f2) > 1 |
|
1471 | return nlinks(f2) > 1 | |
1473 | except OSError: |
|
1472 | except OSError: | |
1474 | return False |
|
1473 | return False | |
1475 | finally: |
|
1474 | finally: | |
1476 |
if f |
|
1475 | if fp is not None: | |
1477 |
f |
|
1476 | fp.close() | |
1478 | for f in (f1, f2): |
|
1477 | for f in (f1, f2): | |
1479 | try: |
|
1478 | try: | |
1480 | if f is not None: |
|
1479 | if f is not None: |
General Comments 0
You need to be logged in to leave comments.
Login now