mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +00:00
parent
b43a70a045
commit
78cf84e136
@ -54,7 +54,7 @@ class FolderManager:
|
|||||||
Track.select(lambda t: t.root_folder == folder).delete(bulk = True)
|
Track.select(lambda t: t.root_folder == folder).delete(bulk = True)
|
||||||
Album.prune()
|
Album.prune()
|
||||||
Artist.prune()
|
Artist.prune()
|
||||||
Folder.prune()
|
Folder.select(lambda f: not f.root and f.path.startswith(folder.path)).delete(bulk = True)
|
||||||
|
|
||||||
folder.delete()
|
folder.delete()
|
||||||
|
|
||||||
|
@ -81,11 +81,15 @@ class Scanner:
|
|||||||
if not self.__is_valid_path(track.path):
|
if not self.__is_valid_path(track.path):
|
||||||
self.remove_file(track.path)
|
self.remove_file(track.path)
|
||||||
|
|
||||||
# Update cover art info
|
# Remove deleted/moved folders and update cover art info
|
||||||
folders = [ folder ]
|
folders = [ folder ]
|
||||||
while folders:
|
while folders:
|
||||||
f = folders.pop()
|
f = folders.pop()
|
||||||
|
|
||||||
|
if not f.root and not os.path.isdir(f.path):
|
||||||
|
Folder.select(lambda sub: sub.path.startswith(f.path)).delete(bulk = True)
|
||||||
|
continue
|
||||||
|
|
||||||
album_name = None
|
album_name = None
|
||||||
track = f.tracks.select().first()
|
track = f.tracks.select().first()
|
||||||
if track is not None:
|
if track is not None:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# Supysonic is a Python implementation of the Subsonic server API.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2017 Alban 'spl0k' Féron
|
# Copyright (C) 2017-2018 Alban 'spl0k' Féron
|
||||||
# 2017 Óscar García Amor
|
# 2017 Óscar García Amor
|
||||||
#
|
#
|
||||||
# Distributed under terms of the GNU AGPLv3 license.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
@ -15,6 +15,8 @@ from . import managers
|
|||||||
from . import api
|
from . import api
|
||||||
from . import frontend
|
from . import frontend
|
||||||
|
|
||||||
|
from .issue101 import Issue101TestCase
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
|
||||||
@ -22,5 +24,7 @@ def suite():
|
|||||||
suite.addTest(managers.suite())
|
suite.addTest(managers.suite())
|
||||||
suite.addTest(api.suite())
|
suite.addTest(api.suite())
|
||||||
suite.addTest(frontend.suite())
|
suite.addTest(frontend.suite())
|
||||||
|
suite.addTest(unittest.makeSuite(Issue101TestCase))
|
||||||
|
|
||||||
return suite
|
return suite
|
||||||
|
|
||||||
|
56
tests/issue101.py
Normal file
56
tests/issue101.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
#
|
||||||
|
# This file is part of Supysonic.
|
||||||
|
# Supysonic is a Python implementation of the Subsonic server API.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 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 Issue101TestCase(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.__dir = tempfile.mkdtemp()
|
||||||
|
init_database('sqlite:', True)
|
||||||
|
with db_session:
|
||||||
|
FolderManager.add('folder', self.__dir)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
release_database()
|
||||||
|
shutil.rmtree(self.__dir)
|
||||||
|
|
||||||
|
def test_issue(self):
|
||||||
|
firstsubdir = tempfile.mkdtemp(dir = self.__dir)
|
||||||
|
subdir = firstsubdir
|
||||||
|
for _ in range(4):
|
||||||
|
subdir = tempfile.mkdtemp(dir = 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()
|
||||||
|
|
||||||
|
shutil.rmtree(firstsubdir)
|
||||||
|
|
||||||
|
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