diff options
Diffstat (limited to 'alot/db/manager.py')
-rw-r--r-- | alot/db/manager.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py index 4d1bb5b2..888e9404 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -18,9 +18,16 @@ from .errors import DatabaseLockedError from .errors import DatabaseROError from .errors import NonexistantObjectError from .thread import Thread -from .utils import is_subdir_of from ..settings.const import settings +def _is_subdir_of(subpath, superpath): + # make both absolute + superpath = os.path.realpath(superpath) + subpath = os.path.realpath(subpath) + + # return true, if the common prefix of both is equal to directory + # e.g. /a/b/c/d.rst and directory is /a/b, the common prefix is /a/b + return os.path.commonprefix([subpath, superpath]) == superpath class FillPipeProcess(multiprocessing.Process): @@ -415,7 +422,7 @@ class DBManager: if self.ro: raise DatabaseROError() - if not is_subdir_of(path, self.path): + if not _is_subdir_of(path, self.path): msg = 'message path %s ' % path msg += ' is not below notmuchs ' msg += 'root path (%s)' % self.path |