mirror of
https://github.com/janeczku/calibre-web
synced 2025-11-17 07:27:10 +00:00
Improved error handling for renaming authors and titles (changes related to filesystem and not only to database)
This commit is contained in:
14
cps/db.py
14
cps/db.py
@@ -26,12 +26,15 @@ def title_sort(title):
|
||||
title = title.replace(prep, '') + ', ' + prep
|
||||
return title.strip()
|
||||
|
||||
|
||||
def lcase(s):
|
||||
return s.lower()
|
||||
|
||||
|
||||
def ucase(s):
|
||||
return s.upper()
|
||||
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
books_authors_link = Table('books_authors_link', Base.metadata,
|
||||
@@ -64,6 +67,7 @@ books_publishers_link = Table('books_publishers_link', Base.metadata,
|
||||
Column('publisher', Integer, ForeignKey('publishers.id'), primary_key=True)
|
||||
)
|
||||
|
||||
|
||||
class Identifiers(Base):
|
||||
__tablename__ = 'identifiers'
|
||||
|
||||
@@ -197,6 +201,7 @@ class Languages(Base):
|
||||
def __repr__(self):
|
||||
return u"<Languages('{0}')>".format(self.lang_code)
|
||||
|
||||
|
||||
class Publishers(Base):
|
||||
__tablename__ = 'publishers'
|
||||
|
||||
@@ -204,7 +209,7 @@ class Publishers(Base):
|
||||
name = Column(String)
|
||||
sort = Column(String)
|
||||
|
||||
def __init__(self, name,sort):
|
||||
def __init__(self, name, sort):
|
||||
self.name = name
|
||||
self.sort = sort
|
||||
|
||||
@@ -212,7 +217,6 @@ class Publishers(Base):
|
||||
return u"<Publishers('{0},{1}')>".format(self.name, self.sort)
|
||||
|
||||
|
||||
|
||||
class Data(Base):
|
||||
__tablename__ = 'data'
|
||||
|
||||
@@ -260,7 +264,7 @@ class Books(Base):
|
||||
identifiers = relationship('Identifiers', backref='books')
|
||||
|
||||
def __init__(self, title, sort, author_sort, timestamp, pubdate, series_index, last_modified, path, has_cover,
|
||||
authors, tags, languages = None):
|
||||
authors, tags, languages=None):
|
||||
self.title = title
|
||||
self.sort = sort
|
||||
self.author_sort = author_sort
|
||||
@@ -300,7 +304,7 @@ def setup_db():
|
||||
global session
|
||||
global cc_classes
|
||||
|
||||
if config.config_calibre_dir is None or config.config_calibre_dir == u'':
|
||||
if config.config_calibre_dir is None or config.config_calibre_dir == u'':
|
||||
content = ub.session.query(ub.Settings).first()
|
||||
content.config_calibre_dir = None
|
||||
content.db_configured = False
|
||||
@@ -309,7 +313,7 @@ def setup_db():
|
||||
return False
|
||||
|
||||
dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
|
||||
engine = create_engine('sqlite:///'+ dbpath, echo=False, isolation_level="SERIALIZABLE")
|
||||
engine = create_engine('sqlite:///' + dbpath, echo=False, isolation_level="SERIALIZABLE")
|
||||
try:
|
||||
conn = engine.connect()
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user