1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Expand path when adding a folder

Expand the path using the system environment
before generating the absolute path.
For example, ~ was not being expanded to
the user's home directory.
This commit is contained in:
Michael Sabin 2018-09-22 02:48:02 -07:00
parent b654f969f5
commit 8c38292abd

View File

@ -33,9 +33,9 @@ class FolderManager:
if Folder.get(name = name, root = True) is not None: if Folder.get(name = name, root = True) is not None:
raise ValueError("Folder '{}' exists".format(name)) raise ValueError("Folder '{}' exists".format(name))
path = os.path.abspath(path) path = os.path.abspath(os.path.expanduser(path))
if not os.path.isdir(path): if not os.path.isdir(path):
raise ValueError("The path doesn't exits or is'nt a directory") raise ValueError("The path doesn't exits or isn't a directory")
if Folder.get(path = path) is not None: if Folder.get(path = path) is not None:
raise ValueError('This path is already registered') raise ValueError('This path is already registered')
if any(path.startswith(p) for p in select(f.path for f in Folder if f.root)): if any(path.startswith(p) for p in select(f.path for f in Folder if f.root)):