feat: rescan now saves to database instead of data files
- Update SeriesApp.rescan() to use database storage by default (use_database=True) - Use SerieScanner.scan_async() for database mode, which saves directly to DB - Fall back to legacy file-based scan() when use_database=False (for CLI compatibility) - Reinitialize SerieList from database after scan when in database mode - Update unit tests to use use_database=False for mocked tests - Add parameter to control storage mode for backward compatibility
This commit is contained in:
@@ -240,7 +240,7 @@ class TestSeriesAppReScan:
|
||||
async def test_rescan_success(
|
||||
self, mock_serie_list, mock_scanner, mock_loaders
|
||||
):
|
||||
"""Test successful directory rescan."""
|
||||
"""Test successful directory rescan (file-based mode)."""
|
||||
test_dir = "/test/anime"
|
||||
app = SeriesApp(test_dir)
|
||||
|
||||
@@ -252,8 +252,8 @@ class TestSeriesAppReScan:
|
||||
app.serie_scanner.reinit = Mock()
|
||||
app.serie_scanner.scan = Mock()
|
||||
|
||||
# Perform rescan
|
||||
await app.rescan()
|
||||
# Perform rescan with file-based mode (use_database=False)
|
||||
await app.rescan(use_database=False)
|
||||
|
||||
# Verify rescan completed
|
||||
app.serie_scanner.reinit.assert_called_once()
|
||||
@@ -266,7 +266,7 @@ class TestSeriesAppReScan:
|
||||
async def test_rescan_with_callback(
|
||||
self, mock_serie_list, mock_scanner, mock_loaders
|
||||
):
|
||||
"""Test rescan with progress callbacks."""
|
||||
"""Test rescan with progress callbacks (file-based mode)."""
|
||||
test_dir = "/test/anime"
|
||||
app = SeriesApp(test_dir)
|
||||
|
||||
@@ -284,8 +284,8 @@ class TestSeriesAppReScan:
|
||||
|
||||
app.serie_scanner.scan = Mock(side_effect=mock_scan)
|
||||
|
||||
# Perform rescan
|
||||
await app.rescan()
|
||||
# Perform rescan with file-based mode (use_database=False)
|
||||
await app.rescan(use_database=False)
|
||||
|
||||
# Verify rescan completed
|
||||
app.serie_scanner.scan.assert_called_once()
|
||||
@@ -297,7 +297,7 @@ class TestSeriesAppReScan:
|
||||
async def test_rescan_cancellation(
|
||||
self, mock_serie_list, mock_scanner, mock_loaders
|
||||
):
|
||||
"""Test rescan cancellation."""
|
||||
"""Test rescan cancellation (file-based mode)."""
|
||||
test_dir = "/test/anime"
|
||||
app = SeriesApp(test_dir)
|
||||
|
||||
@@ -313,9 +313,9 @@ class TestSeriesAppReScan:
|
||||
|
||||
app.serie_scanner.scan = Mock(side_effect=mock_scan)
|
||||
|
||||
# Perform rescan - should handle cancellation
|
||||
# Perform rescan - should handle cancellation (file-based mode)
|
||||
try:
|
||||
await app.rescan()
|
||||
await app.rescan(use_database=False)
|
||||
except Exception:
|
||||
pass # Cancellation is expected
|
||||
|
||||
|
||||
Reference in New Issue
Block a user