mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Missed a few places to make long paths useable in copy_tree
This commit is contained in:
parent
7e014c6851
commit
73d1406e29
@ -71,7 +71,7 @@ class WindowsFileCopier:
|
|||||||
|
|
||||||
def _open_file(self, path: str, retry_on_sharing_violation: bool = True) -> 'winutil.Handle':
|
def _open_file(self, path: str, retry_on_sharing_violation: bool = True) -> 'winutil.Handle':
|
||||||
try:
|
try:
|
||||||
return winutil.create_file(path, winutil.GENERIC_READ,
|
return winutil.create_file(make_long_path_useable(path), winutil.GENERIC_READ,
|
||||||
winutil.FILE_SHARE_DELETE,
|
winutil.FILE_SHARE_DELETE,
|
||||||
winutil.OPEN_EXISTING, winutil.FILE_FLAG_SEQUENTIAL_SCAN)
|
winutil.OPEN_EXISTING, winutil.FILE_FLAG_SEQUENTIAL_SCAN)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
@ -104,23 +104,23 @@ class WindowsFileCopier:
|
|||||||
def copy_all(self) -> None:
|
def copy_all(self) -> None:
|
||||||
for src_path, dest_path in self.copy_map.items():
|
for src_path, dest_path in self.copy_map.items():
|
||||||
with suppress(Exception):
|
with suppress(Exception):
|
||||||
windows_hardlink(src_path, dest_path)
|
windows_hardlink(make_long_path_useable(src_path), make_long_path_useable(dest_path))
|
||||||
shutil.copystat(src_path, dest_path, follow_symlinks=False)
|
shutil.copystat(make_long_path_useable(src_path), make_long_path_useable(dest_path), follow_symlinks=False)
|
||||||
continue
|
continue
|
||||||
handle = self.path_to_handle_map[src_path]
|
handle = self.path_to_handle_map[src_path]
|
||||||
winutil.set_file_pointer(handle, 0, winutil.FILE_BEGIN)
|
winutil.set_file_pointer(handle, 0, winutil.FILE_BEGIN)
|
||||||
with open(dest_path, 'wb') as f:
|
with open(make_long_path_useable(dest_path), 'wb') as f:
|
||||||
sz = 1024 * 1024
|
sz = 1024 * 1024
|
||||||
while True:
|
while True:
|
||||||
raw = winutil.read_file(handle, sz)
|
raw = winutil.read_file(handle, sz)
|
||||||
if not raw:
|
if not raw:
|
||||||
break
|
break
|
||||||
f.write(raw)
|
f.write(raw)
|
||||||
shutil.copystat(src_path, dest_path, follow_symlinks=False)
|
shutil.copystat(make_long_path_useable(src_path), make_long_path_useable(dest_path), follow_symlinks=False)
|
||||||
|
|
||||||
def rename_all(self) -> None:
|
def rename_all(self) -> None:
|
||||||
for src_path, dest_path in self.copy_map.items():
|
for src_path, dest_path in self.copy_map.items():
|
||||||
winutil.move_file(src_path, dest_path)
|
winutil.move_file(make_long_path_useable(src_path), make_long_path_useable(dest_path))
|
||||||
|
|
||||||
def delete_all_source_files(self) -> None:
|
def delete_all_source_files(self) -> None:
|
||||||
for src_path in self.copy_map:
|
for src_path in self.copy_map:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user