mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 11:42:16 +00:00
Fix for bad path encoding
This commit is contained in:
parent
f7ecf08bf2
commit
7417766ac5
@ -207,6 +207,12 @@ class Scanner(Thread):
|
||||
basename = path_or_direntry.name
|
||||
stat = path_or_direntry.stat()
|
||||
|
||||
try:
|
||||
path.encode("utf-8") # Test for badly encoded paths
|
||||
except UnicodeError:
|
||||
self.__stats.errors.append(path)
|
||||
return
|
||||
|
||||
mtime = int(stat.st_mtime)
|
||||
size = stat.st_size
|
||||
|
||||
|
@ -15,6 +15,7 @@ from . import managers
|
||||
from . import api
|
||||
from . import frontend
|
||||
|
||||
from .issue85 import Issue85TestCase
|
||||
from .issue101 import Issue101TestCase
|
||||
from .issue129 import Issue129TestCase
|
||||
from .issue133 import Issue133TestCase
|
||||
@ -29,6 +30,7 @@ def suite():
|
||||
suite.addTest(managers.suite())
|
||||
suite.addTest(api.suite())
|
||||
suite.addTest(frontend.suite())
|
||||
suite.addTest(unittest.makeSuite(Issue85TestCase))
|
||||
suite.addTest(unittest.makeSuite(Issue101TestCase))
|
||||
suite.addTest(unittest.makeSuite(Issue129TestCase))
|
||||
suite.addTest(unittest.makeSuite(Issue133TestCase))
|
||||
|
46
tests/issue85.py
Normal file
46
tests/issue85.py
Normal file
@ -0,0 +1,46 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2020 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import os
|
||||
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.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
|
||||
|
||||
class Issue85TestCase(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):
|
||||
os.mkdir(os.path.join(self.__dir.encode(), b"\xe6"))
|
||||
shutil.copyfile(
|
||||
"tests/assets/folder/silence.mp3",
|
||||
os.path.join(self.__dir.encode(), b"\xe6", b"silence.mp3"),
|
||||
)
|
||||
|
||||
with db_session:
|
||||
scanner = Scanner()
|
||||
scanner.queue_folder("folder")
|
||||
scanner.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user