Fix sync issues if video lies in root of file system
- Fixes #544 - Manual Kodi database reset is necessary
This commit is contained in:
parent
b3f222f117
commit
6718182411
1 changed files with 9 additions and 14 deletions
|
@ -5,13 +5,9 @@ Connect to the Kodi databases (video and music) and operate on them
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import, division, unicode_literals
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from ntpath import dirname
|
|
||||||
from sqlite3 import IntegrityError
|
from sqlite3 import IntegrityError
|
||||||
|
|
||||||
from . import artwork
|
from . import artwork, utils, variables as v, state, path_ops
|
||||||
from . import utils
|
|
||||||
from . import variables as v
|
|
||||||
from . import state
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -109,12 +105,9 @@ class KodiDBMethods(object):
|
||||||
Video DB: Adds all subdirectories to path table while setting a "trail"
|
Video DB: Adds all subdirectories to path table while setting a "trail"
|
||||||
of parent path ids
|
of parent path ids
|
||||||
"""
|
"""
|
||||||
if "\\" in path:
|
parentpath = path_ops.path.abspath(
|
||||||
# Local path
|
path_ops.path.join(path,
|
||||||
parentpath = "%s\\" % dirname(dirname(path))
|
path_ops.decode_path(path_ops.path.pardir)))
|
||||||
else:
|
|
||||||
# Network path
|
|
||||||
parentpath = "%s/" % dirname(dirname(path))
|
|
||||||
pathid = self.get_path(parentpath)
|
pathid = self.get_path(parentpath)
|
||||||
if pathid is None:
|
if pathid is None:
|
||||||
self.cursor.execute("SELECT COALESCE(MAX(idPath),0) FROM path")
|
self.cursor.execute("SELECT COALESCE(MAX(idPath),0) FROM path")
|
||||||
|
@ -125,6 +118,8 @@ class KodiDBMethods(object):
|
||||||
VALUES (?, ?, ?)
|
VALUES (?, ?, ?)
|
||||||
'''
|
'''
|
||||||
self.cursor.execute(query, (pathid, parentpath, datetime))
|
self.cursor.execute(query, (pathid, parentpath, datetime))
|
||||||
|
if parentpath != path:
|
||||||
|
# In case we end up having media in the filesystem root, C:\
|
||||||
parent_id = self.parent_path_id(parentpath)
|
parent_id = self.parent_path_id(parentpath)
|
||||||
query = 'UPDATE path SET idParentPath = ? WHERE idPath = ?'
|
query = 'UPDATE path SET idParentPath = ? WHERE idPath = ?'
|
||||||
self.cursor.execute(query, (parent_id, pathid))
|
self.cursor.execute(query, (parent_id, pathid))
|
||||||
|
|
Loading…
Reference in a new issue