diff --git a/src/calibre/devices/usbms/books.py b/src/calibre/devices/usbms/books.py index 3943ef94f4..fffed41549 100644 --- a/src/calibre/devices/usbms/books.py +++ b/src/calibre/devices/usbms/books.py @@ -18,6 +18,9 @@ class Book(object): self.thumbnail = None self.tags = [] + def __eq__(self, other): + return self.path == other.path + @apply def title_sorter(): doc = '''String to sort the title. If absent, title is returned''' diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index db527c04ea..7529890470 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -109,7 +109,7 @@ class USBMS(Device): if not os.path.exists(newpath): os.makedirs(newpath) - filepath = os.path.join(newpath, names.next()) + filepath = os.path.join(newpath, names.next()) paths.append(filepath) if hasattr(infile, 'read'): @@ -132,7 +132,10 @@ class USBMS(Device): on_card = 1 if location[1] else 0 title, author, mime = cls.extract_book_metadata_by_filename(os.path.basename(path)) - booklists[on_card].append(Book(path, title, author, mime)) + book = Book(path, title, author, mime) + + if not book in booklists[on_card]: + booklists[on_card].append(book) def delete_books(self, paths, end_session=True): for path in paths: