mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Fixes #148 (and other possible related issues)
This commit is contained in:
parent
c938f225e9
commit
deaf17a005
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
47
tests/issue148.py
Normal file
47
tests/issue148.py
Normal file
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user