mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont try to use hardlinks on non-NTFS filesystems on windows
This commit is contained in:
parent
8c79949a1d
commit
4952caec6c
@ -549,13 +549,15 @@ def copyfile(src, dest):
|
|||||||
|
|
||||||
def get_hardlink_function(src, dest):
|
def get_hardlink_function(src, dest):
|
||||||
if iswindows:
|
if iswindows:
|
||||||
import win32file
|
import win32file, win32api
|
||||||
|
root = dest[0] + b':'
|
||||||
try:
|
try:
|
||||||
dt = win32file.GetDriveType(dest[:2])
|
is_suitable = win32file.GetDriveType(root) not in (win32file.DRIVE_REMOTE, win32file.DRIVE_CDROM)
|
||||||
|
# See https://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx
|
||||||
|
supports_hard_links = win32api.GetVolumeInformation(root + os.sep)[3] & 0x00400000
|
||||||
except Exception:
|
except Exception:
|
||||||
dt = win32file.DRIVE_UNKNOWN
|
supports_hard_links = is_suitable = False
|
||||||
hardlink = None if dt in (win32file.DRIVE_REMOTE, win32file.DRIVE_CDROM) else windows_fast_hardlink
|
hardlink = windows_fast_hardlink if is_suitable and supports_hard_links and src[0].lower() == dest[0].lower() else None
|
||||||
hardlink = None if src[0].lower() != dest[0].lower() else hardlink
|
|
||||||
else:
|
else:
|
||||||
hardlink = os.link
|
hardlink = os.link
|
||||||
return hardlink
|
return hardlink
|
||||||
|
Loading…
x
Reference in New Issue
Block a user