Prevent truncating of files when using save file to disk to save a file to itself.

This commit is contained in:
John Schember 2009-05-16 08:25:42 -04:00
parent 4f0dc1d8c7
commit c52966ffa4

View File

@ -220,7 +220,9 @@ class DeviceManager(Thread):
'''Copy books from device to disk'''
for path in paths:
name = path.rpartition('/')[2]
f = open(os.path.join(target, name), 'wb')
dest = os.path.join(target, name)
if os.path.abspath(dest) != os.path.abspath(path):
f = open(dest, 'wb')
self.device.get_file(path, f)
f.close()