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,9 +220,11 @@ 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')
self.device.get_file(path, f)
f.close()
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()
def save_books(self, done, paths, target):
return self.create_job(self._save_books, done, args=[paths, target],