chore: removed locks

This commit is contained in:
Lukas 2025-11-02 15:18:30 +01:00
parent ec987eff80
commit 64e78bb9b8
2 changed files with 5 additions and 82 deletions

View File

@ -35,22 +35,15 @@ Added the following endpoints to `/src/server/api/anime.py`:
- Calls `SeriesApp.Download()` with folder list
- Used when user selects multiple series and clicks download
#### `/api/v1/anime/process/locks` (GET)
- Returns current lock status for rescan and download processes
- Response: `{success: boolean, locks: {rescan: {is_locked: boolean}, download: {is_locked: boolean}}}`
- Used to update UI status indicators and disable buttons during operations
### 2. Updated Frontend API Calls
Modified `/src/server/web/static/js/app.js` to use correct endpoint paths:
| Old Path | New Path | Purpose |
| --------------------------- | ----------------------------- | ------------------------- |
| `/api/add_series` | `/api/v1/anime/add` | Add new series |
| `/api/download` | `/api/v1/anime/download` | Download selected folders |
| `/api/status` | `/api/v1/anime/status` | Get library status |
| `/api/process/locks/status` | `/api/v1/anime/process/locks` | Check process locks |
| Old Path | New Path | Purpose |
| ----------------- | ------------------------ | ------------------------- |
| `/api/add_series` | `/api/v1/anime/add` | Add new series |
| `/api/download` | `/api/v1/anime/download` | Download selected folders |
| `/api/status` | `/api/v1/anime/status` | Get library status |
### 3. Verified Existing Endpoints

View File

@ -26,7 +26,6 @@ class AniWorldApp {
this.loadSeries();
this.initTheme();
this.updateConnectionStatus();
this.startProcessStatusMonitoring();
// Initialize Mobile & Accessibility features
this.initMobileAndAccessibility();
@ -196,7 +195,6 @@ class AniWorldApp {
this.showToast(this.localization.getText('connected-server'), 'success');
this.updateConnectionStatus();
this.checkProcessLocks();
});
this.socket.on('disconnect', () => {
@ -1172,74 +1170,6 @@ class AniWorldApp {
}
}
async checkProcessLocks() {
try {
const response = await this.makeAuthenticatedRequest('/api/anime/process/locks');
if (!response) {
// If no response, set status as idle
this.updateProcessStatus('rescan', false);
this.updateProcessStatus('download', false);
return;
}
// Check if response is actually JSON and not HTML (login page)
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
console.warn('Process locks API returned non-JSON response, likely authentication issue');
// Set status as idle if we can't get proper response
this.updateProcessStatus('rescan', false);
this.updateProcessStatus('download', false);
return;
}
const data = await response.json();
if (data.success) {
const locks = data.locks;
this.updateProcessStatus('rescan', locks.rescan?.is_locked || false);
this.updateProcessStatus('download', locks.download?.is_locked || false);
// Update button states
const rescanBtn = document.getElementById('rescan-btn');
if (rescanBtn) {
if (locks.rescan?.is_locked) {
rescanBtn.disabled = true;
const span = rescanBtn.querySelector('span');
if (span) span.textContent = 'Scanning...';
} else {
rescanBtn.disabled = false;
const span = rescanBtn.querySelector('span');
if (span) span.textContent = 'Rescan';
}
}
} else {
// If API returns error, set status as idle
console.warn('Process locks API returned error:', data.error);
this.updateProcessStatus('rescan', false);
this.updateProcessStatus('download', false);
}
} catch (error) {
console.error('Error checking process locks:', error);
// On error, set status as idle
this.updateProcessStatus('rescan', false);
this.updateProcessStatus('download', false);
}
}
startProcessStatusMonitoring() {
// Initial check on page load
this.checkProcessLocks();
// Check process status every 5 seconds
setInterval(() => {
if (this.isConnected) {
this.checkProcessLocks();
}
}, 5000);
console.log('Process status monitoring started');
}
async showConfigModal() {
const modal = document.getElementById('config-modal');