mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
parent
b43a70a045
commit
78cf84e136
@ -54,7 +54,7 @@ class FolderManager:
|
||||
Track.select(lambda t: t.root_folder == folder).delete(bulk = True)
|
||||
Album.prune()
|
||||
Artist.prune()
|
||||
Folder.prune()
|
||||
Folder.select(lambda f: not f.root and f.path.startswith(folder.path)).delete(bulk = True)
|
||||
|
||||
folder.delete()
|
||||
|
||||
|
@ -81,11 +81,15 @@ class Scanner:
|
||||
if not self.__is_valid_path(track.path):
|
||||
self.remove_file(track.path)
|
||||
|
||||
# Update cover art info
|
||||
# Remove deleted/moved folders and update cover art info
|
||||
folders = [ folder ]
|
||||
while folders:
|
||||
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
|
||||
track = f.tracks.select().first()
|
||||
if track is not None:
|
||||
|
@ -3,7 +3,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# 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
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
@ -15,6 +15,8 @@ from . import managers
|
||||
from . import api
|
||||
from . import frontend
|
||||
|
||||
from .issue101 import Issue101TestCase
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
@ -22,5 +24,7 @@ def suite():
|
||||
suite.addTest(managers.suite())
|
||||
suite.addTest(api.suite())
|
||||
suite.addTest(frontend.suite())
|
||||
suite.addTest(unittest.makeSuite(Issue101TestCase))
|
||||
|
||||
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