Strip trailling periods from filenames calculated by the SQLite backend

This commit is contained in:
Kovid Goyal 2009-07-07 17:13:30 -06:00
parent 6697b9bbb3
commit e0e6ddb6cf
3 changed files with 6 additions and 3 deletions

View File

@ -452,9 +452,12 @@ class OPF(object):
def __init__(self, stream, basedir=os.getcwdu(), unquote_urls=True):
if not hasattr(stream, 'read'):
stream = open(stream, 'rb')
raw = stream.read()
if not raw:
raise ValueError('Empty file: '+getattr(stream, 'name', 'stream'))
self.basedir = self.base_dir = basedir
self.path_to_html_toc = self.html_toc_fragment = None
raw, self.encoding = xml_to_unicode(stream.read(), strip_encoding_pats=True, resolve_entities=True)
raw, self.encoding = xml_to_unicode(raw, strip_encoding_pats=True, resolve_entities=True)
raw = raw[raw.find('<'):]
self.root = etree.fromstring(raw, self.PARSER)
self.metadata = self.metadata_path(self.root)

View File

@ -107,8 +107,6 @@ class Adder(QObject):
self.callback(self.paths, self.names, self.infos)
self.callback_called = True
def update(self):
if not self.ids:
self.timer.stop()

View File

@ -631,6 +631,8 @@ class LibraryDatabase2(LibraryDatabase):
author = sanitize_file_name(authors.split(',')[0][:self.PATH_LIMIT]).decode(filesystem_encoding, 'replace')
title = sanitize_file_name(self.title(id, index_is_id=True)[:self.PATH_LIMIT]).decode(filesystem_encoding, 'replace')
name = title + ' - ' + author
while name.endswith('.'):
name = name[:-1]
return name
def rmtree(self, path):