cyberpanel/aiScanner
usmannasir 2cd361a837 Fix backup file operation failures for API key authentication
Problem: "Failed to backup file before replacement" error when using API key authentication.

Root Cause:
- The externalApp field (which contains the system user for file operations) was sometimes None
- When using API key authentication, the code couldn't determine which user to run commands as

Solution:
- Added fallback logic to ensure we always have a valid user for file operations:
  1. First try wp_site.owner.externalApp
  2. If not set, try Websites.objects.get(domain).externalApp
  3. If still not set, fall back to admin username
- Added detailed error messages and logging throughout backup operations
- Enhanced error reporting to include user context and operation details
- Added validation for backup directory creation with proper error handling

Changes:
- Modified validate_access_token() OPTION 2 and OPTION 3 to ensure external_app is always set
- Enhanced backup and replace operations with better error messages
- Added detailed logging for debugging file operation failures
- Include user context in error messages for easier troubleshooting

This ensures file operations work correctly even when externalApp field is not properly configured.
2025-10-27 14:16:01 +05:00
..
management Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
migrations add aiscanner file patcher 2025-10-26 01:56:36 +05:00
templates/aiScanner enable dark mode 2025-08-05 01:47:22 +05:00
__init__.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
admin.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
aiScannerManager.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
api.py Fix backup file operation failures for API key authentication 2025-10-27 14:16:01 +05:00
apps.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
models.py add aiscanner file patcher 2025-10-26 01:56:36 +05:00
scheduled_views.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
status_api.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
status_models.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
test_api_endpoint.py Fix CyberPanel API key validation for platform callbacks 2025-10-27 13:51:33 +05:00
tests.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
urls.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00
views.py Initial commit for v2.4.3 2025-08-01 14:56:30 +05:00