mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-26 02:44:27 +01:00
Nicer error message when user attempts to set title/author via Edit metadata dialog and one of the files is open in another program.
This commit is contained in:
parent
ff03988bb0
commit
e2cc48381d
1 changed files with 28 additions and 6 deletions
|
|
@ -88,11 +88,22 @@ def initialize(self, db, id_):
|
|||
|
||||
def commit(self, db, id_):
|
||||
title = self.current_val
|
||||
if self.COMMIT:
|
||||
getattr(db, 'set_'+ self.TITLE_ATTR)(id_, title, notify=False)
|
||||
else:
|
||||
getattr(db, 'set_'+ self.TITLE_ATTR)(id_, title, notify=False,
|
||||
commit=False)
|
||||
try:
|
||||
if self.COMMIT:
|
||||
getattr(db, 'set_'+ self.TITLE_ATTR)(id_, title, notify=False)
|
||||
else:
|
||||
getattr(db, 'set_'+ self.TITLE_ATTR)(id_, title, notify=False,
|
||||
commit=False)
|
||||
except (IOError, OSError) as err:
|
||||
if getattr(err, 'errno', -1) == 13: # Permission denied
|
||||
import traceback
|
||||
fname = err.filename if err.filename else 'file'
|
||||
error_dialog(self, _('Permission denied'),
|
||||
_('Could not open %s. Is it being used by another'
|
||||
' program?')%fname, det_msg=traceback.format_exc(),
|
||||
show=True)
|
||||
return False
|
||||
raise
|
||||
return True
|
||||
|
||||
@dynamic_property
|
||||
|
|
@ -225,8 +236,19 @@ def initialize(self, db, id_):
|
|||
|
||||
def commit(self, db, id_):
|
||||
authors = self.current_val
|
||||
self.books_to_refresh |= db.set_authors(id_, authors, notify=False,
|
||||
try:
|
||||
self.books_to_refresh |= db.set_authors(id_, authors, notify=False,
|
||||
allow_case_change=True)
|
||||
except (IOError, OSError) as err:
|
||||
if getattr(err, 'errno', -1) == 13: # Permission denied
|
||||
import traceback
|
||||
fname = err.filename if err.filename else 'file'
|
||||
error_dialog(self, _('Permission denied'),
|
||||
_('Could not open %s. Is it being used by another'
|
||||
' program?')%fname, det_msg=traceback.format_exc(),
|
||||
show=True)
|
||||
return False
|
||||
raise
|
||||
return True
|
||||
|
||||
@dynamic_property
|
||||
|
|
|
|||
Loading…
Reference in a new issue