mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression that broke recursive adding on windows with non ascii file paths
This commit is contained in:
parent
7178234279
commit
c8ca1afe70
@ -43,28 +43,34 @@ class RecursiveFind(QThread):
|
|||||||
self.single_book_per_directory = single
|
self.single_book_per_directory = single
|
||||||
self.canceled = False
|
self.canceled = False
|
||||||
|
|
||||||
|
def walk(self, root):
|
||||||
|
self.books = []
|
||||||
|
for dirpath in os.walk(root):
|
||||||
|
if self.canceled:
|
||||||
|
return
|
||||||
|
self.emit(SIGNAL('update(PyQt_PyObject)'),
|
||||||
|
_('Searching in')+' '+dirpath[0])
|
||||||
|
self.books += list(self.db.find_books_in_directory(dirpath[0],
|
||||||
|
self.single_book_per_directory))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
root = os.path.abspath(self.path)
|
root = os.path.abspath(self.path)
|
||||||
self.books = []
|
|
||||||
if isinstance(root, unicode):
|
|
||||||
root = root.encode(filesystem_encoding)
|
|
||||||
try:
|
try:
|
||||||
for dirpath in os.walk(root):
|
self.walk(root)
|
||||||
if self.canceled:
|
except:
|
||||||
return
|
|
||||||
self.emit(SIGNAL('update(PyQt_PyObject)'),
|
|
||||||
_('Searching in')+' '+dirpath[0])
|
|
||||||
self.books += list(self.db.find_books_in_directory(dirpath[0],
|
|
||||||
self.single_book_per_directory))
|
|
||||||
except Exception, err:
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
try:
|
try:
|
||||||
msg = unicode(err)
|
if isinstance(root, unicode):
|
||||||
except:
|
root = root.encode(filesystem_encoding)
|
||||||
msg = repr(err)
|
self.walk(root)
|
||||||
self.emit(SIGNAL('found(PyQt_PyObject)'), msg)
|
except Exception, err:
|
||||||
return
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
try:
|
||||||
|
msg = unicode(err)
|
||||||
|
except:
|
||||||
|
msg = repr(err)
|
||||||
|
self.emit(SIGNAL('found(PyQt_PyObject)'), msg)
|
||||||
|
return
|
||||||
|
|
||||||
self.books = [formats for formats in self.books if formats]
|
self.books = [formats for formats in self.books if formats]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user