From 922121f726092b67d864abed9c41c0a3216fe09b Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 17 May 2010 11:09:27 +0100 Subject: [PATCH] Calculate author_sort for metadata cache, if it isn't already set --- src/calibre/gui2/device.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 8f4ff6617f..26afc58068 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -19,7 +19,7 @@ from calibre.devices.scanner import DeviceScanner from calibre.gui2 import config, error_dialog, Dispatcher, dynamic, \ pixmap_to_data, warning_dialog, \ question_dialog -from calibre.ebooks.metadata import authors_to_string +from calibre.ebooks.metadata import authors_to_string, authors_to_sort_string from calibre import preferred_encoding from calibre.utils.filenames import ascii_filename from calibre.devices.errors import FreeSpaceError @@ -1133,9 +1133,11 @@ class DeviceGUI(object): resend_metadata = True # Set author_sort if it isn't already asort = getattr(book, 'author_sort', None) - if not asort: - pass + if not asort and book.authors: + book.author_sort = authors_to_sort_string(book.authors) + resend_metadata = True + if resend_metadata: - # Correcting metadata cache on device. + # Correct the metadata cache on device. if self.device_manager.is_device_connected: self.device_manager.sync_booklists(None, booklists)