Commit Graph

46 Commits

Author SHA1 Message Date
Christian Krakau-Louis 9a2c2d20b1 feat(duplication): implement duplicate file handling and detection across processing steps 2026-02-12 02:38:00 +01:00
Christian Krakau-Louis 70757e5644 feat(step-timeout): add automatic recovery for stalled processing steps
- Implement step timeout detection to prevent files from getting stuck in 'pending' state
- Add monitor_stalled_steps periodic task running every minute (Celery Beat)
- Automatically mark in-progress steps as failed if they exceed timeout (default: 10 minutes)
- Add step_timeout configuration setting (default: 600 seconds)
- Recover stalled steps with error message indicating when timeout was triggered
- Fix duplicate check to exclude self-comparison (file not duplicate of itself)

When processing crashes or hangs:
1. Worker detects stalled steps (in_progress for >10 minutes)
2. Marks them as failed with timeout error message
3. Updates UI to show failure status
4. Allows file to be retried or handled by user

This prevents files from being indefinitely stuck in processing state and provides
visibility into what went wrong.
2026-02-12 02:38:00 +01:00
Christian Krakau-Louis 4c11cfd6dd feat(deduplication): implement configurable duplicate file detection
- Add enable_deduplication and show_deduplication_step config options
- Rename hash_file step to check_for_duplicates
- Make deduplication step conditional based on configuration
- Add is_duplicate and duplicate_of_id fields to FileRecord model
- Create database migration for new deduplication fields
- Update process_document task to log deduplication results
- Update step visualization to show/hide step based on config
- Update status calculations to include deduplication step conditionally
- Default: deduplication enabled, step displayed
- Can be configured to hide from UI while still processing
2026-02-12 02:38:00 +01:00
Christian Krakau-Louis 83c65f3c40 feat: enhance processing status tracking and UI display for file details 2026-02-12 01:07:22 +01:00
copilot-swe-agent[bot] 73a0222e56 feat(storage): implement immutable original/processed file storage and collision handling
- Add original_file_path and processed_file_path columns to FileRecord model
- Create database migration for new fields
- Implement get_unique_filepath_with_counter() with -0001 suffix format
- Update process_document to save immutable copy to /workdir/original
- Add force_cloud_ocr parameter to process_document for forced OCR
- Update embed_metadata to use new collision handling
- Update metadata JSON to include file path references
- Add /files/{file_id}/reprocess-with-cloud-ocr API endpoint
- Update processed_file_path in database during embedding

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 20:10:19 +00:00
copilot-swe-agent[bot] 65b6dc6985 feat: Add comprehensive tests and migration utility for status table
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 19:48:17 +00:00
copilot-swe-agent[bot] ad74bc852d feat: Add explicit FileProcessingStep table for status tracking
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 19:45:09 +00:00
copilot-swe-agent[bot] 4fb696e1eb fix: correct file status and metrics to use latest status per step
- Fix _compute_status_from_logs to track latest status per unique step
- Fix _compute_step_summary to count only latest status per step
- Add comprehensive tests for both fixes
- Resolves issue where completed files showed as "Processing"
- Resolves issue where metrics showed incorrect counts

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 18:33:41 +00:00
copilot-swe-agent[bot] 3e78ee4c27 fix(logging): address code review feedback for TaskLogCollector robustness
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 09:15:44 +00:00
copilot-swe-agent[bot] dfa4b16776 feat(tasks): auto-capture worker log output for all tasks via TaskLogCollector
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 09:13:09 +00:00
copilot-swe-agent[bot] b18f5ee13c feat(ui): add verbose worker log detail to processing history on file detail page
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-11 09:06:30 +00:00
copilot-swe-agent[bot] 8edc11da04 refactor: extract shared file-status query logic into utility function
- Created app/utils/file_queries.py with apply_status_filter function
- Updated app/api/files.py to use shared function
- Updated app/views/files.py to use shared function
- Removed unused 'or_' import from app/api/files.py
- Added comprehensive tests in tests/test_file_queries.py
- All tests pass (10 new tests, 14 existing tests verified)

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-10 20:40:11 +00:00
copilot-swe-agent[bot] f4b4ab0328 docs: clarify PDF splitting is page-based, not byte-based
- Add prominent documentation that splitting uses page boundaries
- Update docstring with IMPORTANT note about page-level splitting
- Add test to validate split PDFs are valid and readable
- Update ConfigurationGuide.md to emphasize page-based approach
- Update SECURITY_AUDIT.md with implementation details
- Ensures users understand no risk of corrupted PDFs

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-10 13:51:24 +00:00
copilot-swe-agent[bot] dec7afe712 refactor: extract condition to variable for readability
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-10 11:01:56 +00:00
copilot-swe-agent[bot] 03222c5ef1 refactor: improve file splitting performance and code quality
- Use BytesIO for size checking instead of temporary disk writes (major performance improvement)
- Add constant and comment for PDF overhead multiplier in tests
- Address code review feedback

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-10 10:59:39 +00:00
copilot-swe-agent[bot] ee43687eaa test: fix formatting and linting issues in file upload tests
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-10 10:56:54 +00:00
copilot-swe-agent[bot] 9ad32e40e6 feat(security): add configurable file upload size limits with optional splitting
- Add MAX_UPLOAD_SIZE config (default 1GB) to prevent resource exhaustion
- Add MAX_SINGLE_FILE_SIZE config for optional PDF file splitting
- Implement automatic PDF splitting when files exceed single file limit
- Update upload endpoint to use configured limits instead of hardcoded 500MB
- Add comprehensive tests for upload limits and file splitting
- Document configuration in ConfigurationGuide.md and SECURITY_AUDIT.md
- Reference SECURITY_AUDIT.md in error messages for user guidance

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-10 10:51:30 +00:00
copilot-swe-agent[bot] 3d2b21b3c8 style: fix linting issues (whitespace and formatting)
- Remove trailing whitespace from blank lines
- Apply black formatting to test file
- All tests still pass

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-09 21:05:44 +00:00
copilot-swe-agent[bot] 43b512fee8 refactor(security): improve sanitization logic and tests based on code review
- Change consecutive dots regex to simple replace for better precision
- Update tests to verify exact sanitized output
- Fix docstring syntax warning with raw string
- Add detailed comments explaining sanitization behavior
- All 43 tests pass (21 file upload + 22 filename utils)

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-09 21:04:03 +00:00
copilot-swe-agent[bot] 2bcd774d6d fix(security): enhance path traversal protection in file uploads
- Import and use sanitize_filename utility in ui_upload endpoint
- Enhance sanitize_filename to handle Windows-style paths (backslashes)
- Add protection against path traversal patterns (..)
- Replace all path separators with underscores
- Add comprehensive security tests for Windows-style paths and mixed separators
- All existing tests pass with improved security

This addresses the "Uncontrolled data used in path expression" code scanning alert
by ensuring all user-provided filenames are properly sanitized before being used
in any file operations or stored in the database.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-09 21:00:51 +00:00
copilot-swe-agent[bot] d08040ac4a style: fix all flake8 linter errors across app/ directory
- Run Black formatter and isort on all app/ files
- Remove unused imports (F401) across multiple files
- Add # noqa: F401 for intentional re-exports in celery_worker.py,
  tasks/__init__.py, utils.py, frontend.py, views/base.py
- Fix f-strings without placeholders (F541) in azure.py, notification.py,
  check_credentials.py, upload_to_onedrive.py, settings.py
- Fix bare except (E722) in upload_to_sftp.py
- Fix block comment format (E265) in models.py
- Move imports to top of file to fix E402 in celery_app.py, celery_worker.py
- Fix line-too-long (E501) by wrapping strings in multiple files
- Remove unused variable (F841) in upload_to_nextcloud.py

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 17:42:33 +00:00
copilot-swe-agent[bot] b97c80d6bd fix: address code review feedback on security and type hints
- Use Optional[int] type hint for timeout parameter in oauth_helper
- Replace bare Exception with specific ValueError and JSONDecodeError
- Strengthen rclone remote name validation (must start with alphanumeric)
- Fix path traversal validation to check against workdir for absolute paths
- Add comprehensive comments for security validations

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 08:31:21 +00:00
copilot-swe-agent[bot] d2eb9846d3 style: fix linting issues and remove unused imports
- Remove unused imports from all modified files
- Fix flake8 violations (unused variables, f-strings without placeholders)
- Apply Black formatting consistently
- Shorten long line in google_drive.py

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 08:29:38 +00:00
copilot-swe-agent[bot] 551b23a80c fix(security): reduce code duplication and fix security issues in OAuth and file handling
- Extract common OAuth token exchange logic to shared utility (oauth_helper.py)
- Remove sensitive data logging (client_secret, authorization codes)
- Add path traversal validation in resolve_file_path()
- Add input validation for rclone destination parameter
- Replace bare Exception catches with specific exception types
- Use RuntimeError instead of generic Exception for better error handling

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 08:26:10 +00:00
copilot-swe-agent[bot] 1a01811882 Add encryption and setup wizard features
ENCRYPTION:
- Add cryptography library for secure storage
- Implement Fernet encryption for sensitive settings
- Key derived from SESSION_SECRET
- Auto-encrypt/decrypt transparent to app
- "enc:" prefix identifies encrypted values
- Graceful fallback if crypto unavailable

SETUP WIZARD:
- Detect fresh installs needing configuration
- 3-step wizard: Infrastructure, Security, AI Services
- "/" redirects to wizard if setup required
- Auto-generate session_secret option
- Skip option for advanced users
- Beautiful UI with progress indicators

UI IMPROVEMENTS:
- Enhanced sensitive field display
- Lock icon showing encryption status
- Improved show/hide toggle for passwords
- Better visual hierarchy

FILES:
- app/utils/encryption.py - Encryption utilities
- app/utils/setup_wizard.py - Wizard detection logic
- app/views/wizard.py - Wizard routes
- frontend/templates/setup_wizard.html - Wizard UI
- requirements.txt - Added cryptography
- IMPLEMENTATION_CHECKLIST.md - Status tracking

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 06:18:49 +00:00
copilot-swe-agent[bot] 02fa9ccde4 Address code review feedback
- Clarify test expectations for auth-disabled environment
- Skip timestamp update test (DB backend dependent)
- Document require_admin_access sync/async support
- Restore session_secret and external_hostname as required
- Add comments explaining validation and security requirements

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 06:09:23 +00:00
copilot-swe-agent[bot] c9e1de4845 Fix /settings redirect issue and add OAuth admin support
- Convert require_admin_access to proper decorator pattern
- Fix redirect loop that was sending all users to /
- Add is_admin flag handling for OAuth users (checks groups)
- Update SETTING_METADATA with all 102 settings from config.py
- Improve API admin check with type hints

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-08 06:02:21 +00:00
copilot-swe-agent[bot] 4b4c208035 Security fixes: use tojson filter, fix Tuple import, remove raw value exposure
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-07 22:38:58 +00:00
copilot-swe-agent[bot] 58b960db14 Add comprehensive tests for settings management and fix Union import
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-07 22:33:49 +00:00
copilot-swe-agent[bot] e1bb9de915 Add settings management infrastructure: models, API, views, and database loading
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-07 22:31:06 +00:00
copilot-swe-agent[bot] 775ffa5082 Address code review feedback
- Fixed status filtering to occur before pagination for correct counts
- Resolved N+1 query problem by batch-fetching processing statuses
- Extracted status computation logic to shared utility function
- Changed sort indicator from ⬍ to ↕ for better browser compatibility
- Updated both API and view layers to use shared status utilities

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-07 15:20:59 +00:00
copilot-swe-agent[bot] 9c4cf3d70e Fix notification message to accurately reflect async upload timing
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-06 22:33:16 +00:00
copilot-swe-agent[bot] 8be5b844c3 Add file processing notifications feature
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-02-06 22:31:48 +00:00
Christian Krakau-Louis d79652b494 feat: Add authentication configuration and validation
- Introduced new authentication settings in config.py including `auth_enabled`, `admin_username`, `admin_password`, and `session_secret`.
- Added validation for `session_secret` to ensure it meets security requirements when authentication is enabled.
- Updated main.py to conditionally mount static files and log warnings if the directory is not found.
- Removed unused email template files and added new authentication and notification setup documentation.
- Implemented authentication configuration validation in validators.py and updated settings display.
- Enhanced the user interface with a new login template and SVG assets for branding.
- Added comprehensive guides for setting up authentication and notifications in the documentation.
2025-04-11 03:44:08 +02:00
Christian Krakau-Louis ce91dc8c79 feat: Implement notification system with Apprise integration and credential checks 2025-04-11 01:55:10 +02:00
Christian Krakau-Louis 9a44a7f1f7 Merge branch 'main' into 51-feature-request-switch-google-drive-integration-to-oauth-for-user-based-authentication 2025-04-11 00:18:10 +02:00
Christian Krakau-Louis 4c50c0aae6 Add Google Drive authorization processing and error handling templates
- Implemented `google_drive_callback.html` for processing Google Drive authorization, including UI for success and error states.
- Added JavaScript functionality for exchanging authorization codes, saving settings, and handling folder selection.
- Created `google_drive_callback_error.html` to display error messages during the authorization process.
2025-04-11 00:13:57 +02:00
Christian Krakau-Louis b258dd2f29 feat: Add OpenAI and Azure AI API endpoints with connection testing functionality 2025-04-09 08:59:30 +02:00
Christian Krakau-Louis 2f822adeb7 feat: Add OpenAI and Azure AI API endpoints with connection testing functionality 2025-04-09 07:08:38 +02:00
Christian Krakau-Louis 2cafda11dd feat: update version to 0.4.3-dev, add file deletion feature, and refactor API structure 2025-04-03 15:55:34 +02:00
Christian Krakau-Louis dc19608ec1 feat: update version to 0.4.2-dev, add self-hosted Font Awesome loader, and enhance provider status icons 2025-04-03 13:29:40 +02:00
Christian Krakau-Louis af1a76a813 feat: refactor OneDrive integration to use session storage for credentials and enhance error handling
feat: updated System Status Dashboard
2025-04-03 12:44:17 +02:00
Christian Krakau-Louis 94889e9e41 feat: implement Dropbox integration with OAuth setup and error handling 2025-04-03 10:35:55 +02:00
Christian Krakau-Louis c3df8107d8 feat: enhance FTP configuration with TLS options and update documentation
Enhanced OneDrive workflow and tested
2025-04-02 02:57:30 +02:00
Christian Krakau-Louis ceaed1a081 feat: add Uptime Kuma integration with periodic ping task and configuration options 2025-04-01 22:44:46 +02:00
Christian Krakau-Louis 6972fb7505 feat: implement Google Drive integration and enhance documentation for new features 2025-04-01 04:44:00 +02:00