Show More
@@ -56,6 +56,9 b' class _BY_HANDLE_FILE_INFORMATION(ctypes' | |||||
56 |
|
56 | |||
57 | _OPEN_EXISTING = 3 |
|
57 | _OPEN_EXISTING = 3 | |
58 |
|
58 | |||
|
59 | # SetFileAttributes | |||
|
60 | _FILE_ATTRIBUTE_NORMAL = 0x80 | |||
|
61 | ||||
59 | # Process Security and Access Rights |
|
62 | # Process Security and Access Rights | |
60 | _PROCESS_QUERY_INFORMATION = 0x0400 |
|
63 | _PROCESS_QUERY_INFORMATION = 0x0400 | |
61 |
|
64 | |||
@@ -350,9 +353,15 b' def unlink(f):' | |||||
350 |
|
353 | |||
351 | try: |
|
354 | try: | |
352 | os.unlink(temp) |
|
355 | os.unlink(temp) | |
353 | except: |
|
356 | except OSError: | |
354 | # Some very rude AV-scanners on Windows may cause this unlink to fail. |
|
357 | # The unlink might have failed because the READONLY attribute may heave | |
355 | # Not aborting here just leaks the temp file, whereas aborting at this |
|
358 | # been set on the original file. Rename works fine with READONLY set, | |
356 | # point may leave serious inconsistencies. Ideally, we would notify |
|
359 | # but not os.unlink. Reset all attributes and try again. | |
357 | # the user in this case here. |
|
360 | _kernel32.SetFileAttributesA(temp, _FILE_ATTRIBUTE_NORMAL) | |
358 |
|
|
361 | try: | |
|
362 | os.unlink(temp) | |||
|
363 | except OSError: | |||
|
364 | # The unlink might have failed due to some very rude AV-Scanners. | |||
|
365 | # Leaking a tempfile is the lesser evil than aborting here and | |||
|
366 | # leaving some potentially serious inconsistencies. | |||
|
367 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now