1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-09-19 10:51:04 +00:00

Merge branch 'dependencies'

This commit is contained in:
Alban Féron 2019-07-13 17:09:56 +02:00
commit 8a3ea151cc
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165
4 changed files with 9 additions and 18 deletions

View File

@ -20,7 +20,7 @@ reqs = [
"Pillow",
"requests>=1.0.0",
"mutagen>=1.33",
"scandir<2.0.0",
"scandir<2.0.0; python_version <= '2.7'",
"watchdog>=0.8.0",
"zipstream",
]

View File

@ -10,9 +10,9 @@
# Try built-in scandir, fall back to the package for Python 2.7
try:
from os import scandir, DirEntry
from os import scandir
except ImportError:
from scandir import scandir, DirEntry
from scandir import scandir
# os.replace was added in Python 3.3, provide a fallback for Python 2.7
try:

View File

@ -20,7 +20,7 @@ from .covers import find_cover_in_folder, has_embedded_cover, CoverFile
from .db import Folder, Artist, Album, Track, User
from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack
from .db import RatingFolder, RatingTrack
from .py23 import scandir, strtype, DirEntry, Queue, QueueEmpty
from .py23 import scandir, strtype, Queue, QueueEmpty
logger = logging.getLogger(__name__)
@ -194,16 +194,7 @@ class Scanner(Thread):
@db_session
def scan_file(self, path_or_direntry):
if not isinstance(path_or_direntry, (strtype, DirEntry)):
raise TypeError(
"Expecting string or DirEntry, got " + str(type(path_or_direntry))
)
if isinstance(path_or_direntry, DirEntry):
path = path_or_direntry.path
basename = path_or_direntry.name
stat = path_or_direntry.stat()
else:
if isinstance(path_or_direntry, strtype):
path = path_or_direntry
if not os.path.exists(path):
@ -211,6 +202,10 @@ class Scanner(Thread):
basename = os.path.basename(path)
stat = os.stat(path)
else:
path = path_or_direntry.path
basename = path_or_direntry.name
stat = path_or_direntry.stat()
mtime = int(stat.st_mtime)
size = stat.st_size

View File

@ -72,10 +72,6 @@ class ScannerTestCase(unittest.TestCase):
@db_session
def test_scan_file(self):
track = db.Track.select().first()
self.assertRaises(TypeError, self.scanner.scan_file, None)
self.assertRaises(TypeError, self.scanner.scan_file, track)
self.scanner.scan_file("/some/inexistent/path")
commit()
self.assertEqual(db.Track.select().count(), 1)