feat(scheduler): add folder_scan_enabled toggle to SchedulerConfig

- Add folder_scan_enabled boolean field (default false) to SchedulerConfig
- Update data/config.json example with new field
- Add checkbox to setup.html and include in JS payload
- Handle field in auth.py setup endpoint
- Expose field in scheduler API response
- Log and return field in scheduler_service.py
- Update docs/CONFIGURATION.md and docs/ARCHITECTURE.md
- Update index.html UI, app.js and scheduler-config.js handlers
- Verified backward compatibility: old configs load with default False
This commit is contained in:
2026-05-11 21:02:05 +02:00
parent 079f1f99e3
commit c39ae9d0fc
12 changed files with 197 additions and 140 deletions

View File

@@ -76,6 +76,8 @@ async def setup_auth(req: SetupRequest):
config.scheduler.schedule_days = req.scheduler_schedule_days
if req.scheduler_auto_download_after_rescan is not None:
config.scheduler.auto_download_after_rescan = req.scheduler_auto_download_after_rescan
if req.scheduler_folder_scan_enabled is not None:
config.scheduler.folder_scan_enabled = req.scheduler_folder_scan_enabled
# Update logging configuration
if req.logging_level:

View File

@@ -31,6 +31,7 @@ def _build_response(config: SchedulerConfig) -> Dict[str, Any]:
"schedule_time": config.schedule_time,
"schedule_days": config.schedule_days,
"auto_download_after_rescan": config.auto_download_after_rescan,
"folder_scan_enabled": config.folder_scan_enabled,
},
"status": {
"is_running": runtime.get("is_running", False),

View File

@@ -73,6 +73,9 @@ class SetupRequest(BaseModel):
scheduler_auto_download_after_rescan: Optional[bool] = Field(
default=False, description="Auto-download missing episodes after rescan"
)
scheduler_folder_scan_enabled: Optional[bool] = Field(
default=False, description="Run folder maintenance during scheduled run"
)
# Logging configuration
logging_level: Optional[str] = Field(

View File

@@ -39,6 +39,11 @@ class SchedulerConfig(BaseModel):
description="Automatically queue and start downloads for all missing "
"episodes after a scheduled rescan completes.",
)
folder_scan_enabled: bool = Field(
default=False,
description="Run folder maintenance (NFO repair, folder renaming, "
"poster checks) during the scheduled run.",
)
@field_validator("schedule_time")
@classmethod

View File

@@ -145,6 +145,7 @@ class SchedulerService:
schedule_time=config.schedule_time,
schedule_days=config.schedule_days,
auto_download=config.auto_download_after_rescan,
folder_scan=config.folder_scan_enabled,
)
if not self._scheduler or not self._scheduler.running:
@@ -204,6 +205,9 @@ class SchedulerService:
"auto_download_after_rescan": (
self._config.auto_download_after_rescan if self._config else False
),
"folder_scan_enabled": (
self._config.folder_scan_enabled if self._config else False
),
"last_run": self._last_scan_time.isoformat() if self._last_scan_time else None,
"next_run": next_run,
"scan_in_progress": self._scan_in_progress,

View File

@@ -1561,6 +1561,8 @@ class AniWorldApp {
document.getElementById('scheduled-rescan-enabled').checked = !!config.enabled;
document.getElementById('scheduled-rescan-time').value = config.schedule_time || '03:00';
document.getElementById('auto-download-after-rescan').checked = !!config.auto_download_after_rescan;
const folderScanEl = document.getElementById('folder-scan-enabled');
if (folderScanEl) folderScanEl.checked = !!config.folder_scan_enabled;
// Update day-of-week checkboxes
const days = Array.isArray(config.schedule_days) ? config.schedule_days : ['mon','tue','wed','thu','fri','sat','sun'];
@@ -1603,6 +1605,8 @@ class AniWorldApp {
const enabled = document.getElementById('scheduled-rescan-enabled').checked;
const scheduleTime = document.getElementById('scheduled-rescan-time').value || '03:00';
const autoDownload = document.getElementById('auto-download-after-rescan').checked;
const folderScanEl = document.getElementById('folder-scan-enabled');
const folderScan = folderScanEl ? folderScanEl.checked : false;
// Collect checked day-of-week values
const scheduleDays = ['mon','tue','wed','thu','fri','sat','sun']
@@ -1618,7 +1622,8 @@ class AniWorldApp {
enabled: enabled,
schedule_time: scheduleTime,
schedule_days: scheduleDays,
auto_download_after_rescan: autoDownload
auto_download_after_rescan: autoDownload,
folder_scan_enabled: folderScan
})
});

View File

@@ -35,6 +35,11 @@ AniWorld.SchedulerConfig = (function() {
autoDownload.checked = config.auto_download_after_rescan || false;
}
const folderScan = document.getElementById('folder-scan-enabled');
if (folderScan) {
folderScan.checked = config.folder_scan_enabled || false;
}
// Update schedule day checkboxes
const days = config.schedule_days || ['mon','tue','wed','thu','fri','sat','sun'];
['mon','tue','wed','thu','fri','sat','sun'].forEach(function(day) {
@@ -82,12 +87,16 @@ AniWorld.SchedulerConfig = (function() {
const autoDownloadEl = document.getElementById('auto-download-after-rescan');
const autoDownload = autoDownloadEl ? autoDownloadEl.checked : false;
const folderScanEl = document.getElementById('folder-scan-enabled');
const folderScan = folderScanEl ? folderScanEl.checked : false;
// POST directly to the scheduler config endpoint
const payload = {
enabled: enabled,
schedule_time: scheduleTime,
schedule_days: scheduleDays,
auto_download_after_rescan: autoDownload
auto_download_after_rescan: autoDownload,
folder_scan_enabled: folderScan
};
const response = await AniWorld.ApiClient.post(API.SCHEDULER_CONFIG, payload);

View File

@@ -309,6 +309,17 @@
</label>
</div>
<div class="config-item">
<label class="checkbox-label">
<input type="checkbox" id="folder-scan-enabled">
<span class="checkbox-custom"></span>
<span data-text="folder-scan-enabled">Run folder maintenance (NFO repair, renaming, poster checks)</span>
</label>
<small class="config-hint" data-text="folder-scan-hint">
Automatically repair NFOs, rename folders, and check posters during scheduled runs.
</small>
</div>
<div class="config-item scheduler-status" id="scheduler-status">
<div class="scheduler-info">

View File

@@ -479,6 +479,13 @@
<span>Auto-download missing episodes after rescan</span>
</label>
</div>
<div class="form-group">
<label class="form-checkbox">
<input type="checkbox" id="scheduler_folder_scan" name="scheduler_folder_scan">
<span>Run folder maintenance (NFO repair, renaming, poster checks)</span>
</label>
<div class="form-help">Automatically repair NFOs, rename folders, and check posters during scheduled runs</div>
</div>
</div>
</div>
@@ -761,6 +768,7 @@
scheduler_schedule_time: document.getElementById('scheduler_schedule_time').value || '03:00',
scheduler_schedule_days: Array.from(document.querySelectorAll('.scheduler-day-setup-cb:checked')).map(cb => cb.value),
scheduler_auto_download_after_rescan: document.getElementById('scheduler_auto_download').checked,
scheduler_folder_scan_enabled: document.getElementById('scheduler_folder_scan').checked,
logging_level: document.getElementById('logging_level').value,
logging_file: document.getElementById('logging_file').value.trim() || null,
logging_max_bytes: document.getElementById('logging_max_bytes').value ?