Fix a bug in the Save to disk function that could cause saving of multiple books to fail on multi-core machines

This commit is contained in:
Kovid Goyal 2009-12-18 11:26:19 -07:00
parent a5ab3a2675
commit 3f745e44e1
3 changed files with 16 additions and 3 deletions

View File

@ -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 = []

View File

@ -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

View File

@ -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: