use os.sep
This commit is contained in:
parent
aa34f96f48
commit
8537026ef1
1 changed files with 8 additions and 8 deletions
|
@ -28,7 +28,7 @@ def remove_missing():
|
||||||
dirty = False
|
dirty = False
|
||||||
with db.session():
|
with db.session():
|
||||||
prefs = settings.preferences
|
prefs = settings.preferences
|
||||||
prefix = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/')
|
prefix = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books' + os.sep)
|
||||||
if os.path.exists(prefix):
|
if os.path.exists(prefix):
|
||||||
for f in File.query:
|
for f in File.query:
|
||||||
if not state.tasks.connected:
|
if not state.tasks.connected:
|
||||||
|
@ -66,9 +66,9 @@ def add_file(id, f, prefix, from_=None):
|
||||||
def run_scan():
|
def run_scan():
|
||||||
remove_missing()
|
remove_missing()
|
||||||
prefs = settings.preferences
|
prefs = settings.preferences
|
||||||
prefix = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/')
|
prefix = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books' + os.sep)
|
||||||
if not prefix[-1] == '/':
|
if not prefix[-1] == os.sep:
|
||||||
prefix += '/'
|
prefix += os.sep
|
||||||
assert isinstance(prefix, str)
|
assert isinstance(prefix, str)
|
||||||
books = []
|
books = []
|
||||||
for root, folders, files in os.walk(prefix):
|
for root, folders, files in os.walk(prefix):
|
||||||
|
@ -105,10 +105,10 @@ def run_import(options=None):
|
||||||
prefix = os.path.expanduser(options.get('path', prefs['importPath']))
|
prefix = os.path.expanduser(options.get('path', prefs['importPath']))
|
||||||
if os.path.islink(prefix):
|
if os.path.islink(prefix):
|
||||||
prefix = os.path.realpath(prefix)
|
prefix = os.path.realpath(prefix)
|
||||||
if not prefix[-1] == '/':
|
if not prefix[-1] == os.sep:
|
||||||
prefix += '/'
|
prefix += os.sep
|
||||||
prefix_books = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/')
|
prefix_books = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books' + os.sep)
|
||||||
prefix_imported = os.path.join(prefix_books, 'Imported/')
|
prefix_imported = os.path.join(prefix_books, 'Imported' + os.sep)
|
||||||
if prefix_books.startswith(prefix) or prefix.startswith(prefix_books):
|
if prefix_books.startswith(prefix) or prefix.startswith(prefix_books):
|
||||||
error = 'invalid path'
|
error = 'invalid path'
|
||||||
elif not os.path.exists(prefix):
|
elif not os.path.exists(prefix):
|
||||||
|
|
Loading…
Reference in a new issue