mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 10:54:53 +02:00
When changing the title/author of a book, use hard links instead of copying the file, for a large speedup.
This commit is contained in:
parent
0d532dd522
commit
5d3418f22c
2 changed files with 11 additions and 1 deletions
|
|
@ -646,7 +646,7 @@ def set_path(self, index, index_is_id=False):
|
|||
spath = os.path.join(self.library_path, *current_path.split('/'))
|
||||
tpath = os.path.join(self.library_path, *path.split('/'))
|
||||
|
||||
wam = WindowsAtomicFolderMove(spath) if iswindows else None
|
||||
wam = WindowsAtomicFolderMove(spath) if iswindows and current_path else None
|
||||
try:
|
||||
if not os.path.exists(tpath):
|
||||
os.makedirs(tpath)
|
||||
|
|
@ -1375,6 +1375,11 @@ def copy_format_to(self, index, fmt, dest, index_is_id=False,
|
|||
if hasattr(dest, 'flush'):
|
||||
dest.flush()
|
||||
elif dest and not samefile(dest, path):
|
||||
try:
|
||||
os.link(path, dest)
|
||||
return
|
||||
except:
|
||||
pass
|
||||
with lopen(path, 'rb') as f, lopen(dest, 'wb') as d:
|
||||
shutil.copyfileobj(f, d)
|
||||
|
||||
|
|
|
|||
|
|
@ -300,6 +300,11 @@ def copy_path_to(self, path, dest):
|
|||
if handle is None:
|
||||
raise ValueError(u'The file %r did not exist when this move'
|
||||
' operation was started'%path)
|
||||
try:
|
||||
win32file.CreateHardLink(dest, path)
|
||||
return
|
||||
except:
|
||||
pass
|
||||
with lopen(dest, 'wb') as f:
|
||||
while True:
|
||||
hr, raw = win32file.ReadFile(handle, 1024*1024)
|
||||
|
|
|
|||
Loading…
Reference in a new issue