Compare filesizes to verify the hardlinking worked on windows, more robust

This commit is contained in:
Kovid Goyal 2012-10-29 09:01:28 +05:30
parent 7a174b5bc8
commit 88620ed588

View File

@ -307,7 +307,7 @@ class WindowsAtomicFolderMove(object):
' operation was started'%path) ' operation was started'%path)
try: try:
win32file.CreateHardLink(dest, path) win32file.CreateHardLink(dest, path)
if not os.path.exists(dest): if os.path.getsize(dest) != os.path.getsize(path):
raise Exception('This apparently can happen on network shares. Sigh.') raise Exception('This apparently can happen on network shares. Sigh.')
return return
except: except:
@ -348,7 +348,7 @@ def hardlink_file(src, dest):
if iswindows: if iswindows:
import win32file import win32file
win32file.CreateHardLink(dest, src) win32file.CreateHardLink(dest, src)
if not os.path.exists(dest): if os.path.getsize(dest) != os.path.getsize(src):
raise Exception('This apparently can happen on network shares. Sigh.') raise Exception('This apparently can happen on network shares. Sigh.')
return return
os.link(src, dest) os.link(src, dest)