diff --git a/supysonic/db.py b/supysonic/db.py index f283e8e..6d4bb49 100644 --- a/supysonic/db.py +++ b/supysonic/db.py @@ -74,11 +74,11 @@ class Folder(PathMixin, db.Entity): id = PrimaryKey(UUID, default = uuid4) root = Required(bool, default = False) - name = Required(str) - path = Required(str, 4096) # unique + name = Required(str, autostrip = False) + path = Required(str, 4096, autostrip = False) # unique _path_hash = Required(buffer, column = 'path_hash') created = Required(datetime, precision = 0, default = now) - cover_art = Optional(str, nullable = True) + cover_art = Optional(str, nullable = True, autostrip = False) last_scan = Required(int, default = 0) parent = Optional(lambda: Folder, reverse = 'children', column = 'parent_id') @@ -227,7 +227,7 @@ class Track(PathMixin, db.Entity): bitrate = Required(int) - path = Required(str, 4096) # unique + path = Required(str, 4096, autostrip = False) # unique _path_hash = Required(buffer, column = 'path_hash') content_type = Required(str) created = Required(datetime, precision = 0, default = now) diff --git a/tests/__init__.py b/tests/__init__.py index 6df5548..cdc0b64 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -19,6 +19,7 @@ from .issue101 import Issue101TestCase from .issue129 import Issue129TestCase from .issue133 import Issue133TestCase from .issue139 import Issue139TestCase +from .issue148 import Issue148TestCase def suite(): suite = unittest.TestSuite() @@ -31,6 +32,7 @@ def suite(): suite.addTest(unittest.makeSuite(Issue129TestCase)) suite.addTest(unittest.makeSuite(Issue133TestCase)) suite.addTest(unittest.makeSuite(Issue139TestCase)) + suite.addTest(unittest.makeSuite(Issue148TestCase)) return suite diff --git a/tests/issue148.py b/tests/issue148.py new file mode 100644 index 0000000..6b6c706 --- /dev/null +++ b/tests/issue148.py @@ -0,0 +1,47 @@ +# coding: utf-8 +# +# This file is part of Supysonic. +# Supysonic is a Python implementation of the Subsonic server API. +# +# Copyright (C) 2019 Alban 'spl0k' FĂ©ron +# +# Distributed under terms of the GNU AGPLv3 license. + +import os.path +import shutil +import tempfile +import unittest + +from pony.orm import db_session + +from supysonic.db import init_database, release_database +from supysonic.db import Folder +from supysonic.managers.folder import FolderManager +from supysonic.scanner import Scanner + +class Issue148TestCase(unittest.TestCase): + def setUp(self): + self.__dir = tempfile.mkdtemp() + init_database('sqlite:') + with db_session: + FolderManager.add('folder', self.__dir) + + def tearDown(self): + release_database() + shutil.rmtree(self.__dir) + + def test_issue(self): + subdir = os.path.join(self.__dir, ' ') + os.makedirs(subdir) + shutil.copyfile('tests/assets/folder/silence.mp3', os.path.join(subdir, 'silence.mp3')) + + scanner = Scanner() + with db_session: + folder = Folder.select(lambda f: f.root).first() + scanner.scan(folder) + scanner.finish() + + +if __name__ == '__main__': + unittest.main() +