Skip to content

Conversation

@jorben
Copy link
Collaborator

@jorben jorben commented Feb 10, 2026

Summary

  • Add FileWaitUtil with retry logic to handle Windows antivirus scanning delays and filesystem sync issues that cause "PDF file not found" errors
  • Enhance file upload handlers with directory write permission checks, post-copy verification, and empty file detection
  • Fix path traversal vulnerability in uploadFileContent handler
  • Fix TaskRepository.create ignoring caller-provided id and status values

Changes

Core - File Wait Utility (New)

  • FileWaitUtil.ts: Shared static utility that retries file access checks (5 attempts, 1s interval) with diagnostic logging when files are not found

Core - Splitters

  • PDFSplitter.ts: Integrate FileWaitUtil.waitForFile() pre-check before PDF processing
  • ImageSplitter.ts: Integrate FileWaitUtil.waitForFile() pre-check, remove redundant fs.access call

Main - File Upload Handlers

  • file.handler.ts: Add fs.accessSync(W_OK) directory writability check, post-copy/write file existence and size verification, diagnostic logging, and path.basename() sanitization for drag-and-drop filenames

Core - Task Repository

  • TaskRepository.ts: Use caller-provided id (fallback to uuidv4()), use nullish coalescing (??) for progress and status instead of hardcoded values

Tests

  • Update mocks for FileWaitUtil, fs.accessSync, and fs.constants across 4 test files

Motivation

Users on Windows reported task failures with "PDF file not found" after uploading files. The issue could not be reproduced in development but is likely caused by environmental factors such as antivirus software temporarily locking newly copied files, directory write permission restrictions, or filesystem sync delays.

Test Plan

  • All 757 tests pass
  • TypeScript type-check passes (tsc --noEmit)
  • Manual test: upload PDF via file dialog on Windows
  • Manual test: upload PDF via drag-and-drop on Windows
  • Verify diagnostic logs appear when file access is delayed

Refs #20

🤖 Generated with Claude Code

…n for Windows

Add FileWaitUtil to retry file access before splitting, addressing
"PDF file not found" errors reported on Windows where antivirus
software or filesystem sync delays may temporarily lock newly
copied files.

- Add FileWaitUtil with retry logic (5 attempts, 1s interval) and
  diagnostic logging for file availability checks
- Enhance file upload handlers with directory write permission
  verification, post-copy/write validation, and empty file detection
- Fix path traversal vulnerability in uploadFileContent by sanitizing
  filename with path.basename()
- Fix TaskRepository.create ignoring caller-provided id and status
  values (status was hardcoded to 0 instead of using passed value)
- Update PDFSplitter and ImageSplitter to use shared FileWaitUtil
- Remove redundant fs.access call in ImageSplitter after pre-check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant