From 3f745e44e12f13abb1c3f5f731a6af9d9e819771 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Dec 2009 11:26:19 -0700 Subject: [PATCH] Fix a bug in the Save to disk function that could cause saving of multiple books to fail on multi-core machines --- src/calibre/debug.py | 9 ++++++++- src/calibre/devices/eslick/driver.py | 2 +- src/calibre/library/save_to_disk.py | 8 +++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 2115b1b88c..bb958996b6 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -65,7 +65,14 @@ def debug_device_driver(): from calibre.devices.scanner import DeviceScanner s = DeviceScanner() s.scan() - print 'USB devices on system:\n', pprint.pprint(s.devices) + devices = s.devices + if not iswindows: + devices = [list(x) for x in devices] + for d in devices: + for i in range(3): + d[i] = hex(d[i]) + + print 'USB devices on system:\n', pprint.pprint(devices) if iswindows: wmi = __import__('wmi', globals(), locals(), [], -1) drives = [] diff --git a/src/calibre/devices/eslick/driver.py b/src/calibre/devices/eslick/driver.py index 5bdb1c04d2..4854c5c730 100644 --- a/src/calibre/devices/eslick/driver.py +++ b/src/calibre/devices/eslick/driver.py @@ -14,7 +14,7 @@ class ESLICK(USBMS): name = 'ESlick Device Interface' gui_name = 'Foxit ESlick' description = _('Communicate with the ESlick eBook reader.') - author = _('Kovid Goyal') + author = 'Kovid Goyal' supported_platforms = ['windows', 'osx', 'linux'] # Ordered list of supported formats diff --git a/src/calibre/library/save_to_disk.py b/src/calibre/library/save_to_disk.py index aedba05720..e169222bb5 100644 --- a/src/calibre/library/save_to_disk.py +++ b/src/calibre/library/save_to_disk.py @@ -153,8 +153,14 @@ def save_book_to_disk(id, db, root, opts, length): base_path = os.path.join(root, *components) base_name = os.path.basename(base_path) dirpath = os.path.dirname(base_path) - if not os.path.exists(dirpath): + # Don't test for existence first are the test could fail but + # another worker process could create the directory before + # the call to makedirs + try: os.makedirs(dirpath) + except BaseException: + if not os.path.exists(dirpath): + raise cdata = db.cover(id, index_is_id=True) if opts.save_cover: