From 88620ed588de3c6ef7df25bc8a2bd2325f5c152f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 29 Oct 2012 09:01:28 +0530 Subject: [PATCH] Compare filesizes to verify the hardlinking worked on windows, more robust --- src/calibre/utils/filenames.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/filenames.py b/src/calibre/utils/filenames.py index 3a327b214c..0960a50c1c 100644 --- a/src/calibre/utils/filenames.py +++ b/src/calibre/utils/filenames.py @@ -307,7 +307,7 @@ class WindowsAtomicFolderMove(object): ' operation was started'%path) try: 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.') return except: @@ -348,7 +348,7 @@ def hardlink_file(src, dest): if iswindows: import win32file 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.') return os.link(src, dest)