Replaces manual conversion of absolute paths to vault-relative paths with a utility method to improve code readability and maintainability across various modules. Removes redundant code and streamlines path handling operations.
This refactoring helps ensure consistent path management and reduces potential errors related to path conversion.
Relates to obsidian-bot-review
Introduces toVaultRelativePath method to centralize path conversions,
reducing code duplication and improving maintainability. Extracts
image download completion logic into handleDownloadComplete for clarity.
Relates to obsidian-bot-review
Resolves critical bugs where directories and files were being created with
doubled paths (e.g., /vault/vault/path) due to incorrect handling of absolute
vs vault-relative paths when using Obsidian's vault adapter.
## Root Cause
The vault.adapter methods (mkdir, write, readBinary, etc.) expect vault-relative
paths, but many parts of the codebase were passing absolute filesystem paths.
This caused the adapter to prepend the vault path again, resulting in doubled
paths like: /Users/user/vault/Users/user/vault/exports
## Changes
### Core Path Handling
- **TempDirectoryManager**: Switched to Node's fs module for temp directory
operations since external tools (pdf2img, ImageMagick, Pandoc) require
absolute filesystem paths and cannot use vault adapter
- **PathUtils.ensureDir()**: Enhanced error messages to provide context about
missing parent directories and permission issues
### Path Conversion Pattern
Implemented consistent pattern throughout codebase: convert absolute paths to
vault-relative before vault.adapter operations by:
1. Checking if path starts with vault base path
2. Stripping vault base path
3. Removing leading slash/backslash
4. Passing vault-relative path to vault.adapter
### Fixed Locations
- **ImageOptimizer**: Convert paths before vault.adapter operations (3 locations)
- **EmbedProcessor**:
- downloadRemoteImage(): path conversion for writeBinary
- copyImageToVaultTemp(): path conversion for vault.adapter operations
- processImageEmbeds(): WebP conversion temp directory
- **PandocTypstConverter**: Use fs module for temp markdown file operations
- **PathResolver**: Convert output folder paths before ensureDir
- **PdfToImageConverter**: Convert output directory path before ensureDir
- **EmbeddedTemplateManager**: Convert template directory paths (2 locations)
### Additional Improvements
- **PathResolver**: Added validation for empty/missing output folder with
clear error message guiding users to plugin settings
- **ESLint**: Changed sentence-case rule from error to warning to reduce
linter noise during development
## Impact
- Fixes directories being created in wrong locations with doubled paths
- Ensures temp directories are accessible by external CLI tools
- Improves error messages for directory creation failures
- Maintains compatibility with both Obsidian's vault adapter and Node's fs
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Applies linting rules to the codebase and resolves identified issues.
Addresses:
- Renamed headings in settings tabs to improve UI consistency and style.
- Resolved require() style imports
- Added void operator to ensure correct promise handling.
- Replaced deprecated Obsidian API calls.
- Enforces sentence case to enhance UI text consistency.
Simplifies the path joining logic by leveraging the built-in `path.join` method directly.
This change removes the manual iteration and absolute path handling, resulting in more concise and readable code.
Ensures correct path handling on Windows.
Addresses issues with path construction on Windows by using `path.isAbsolute()` to correctly handle absolute paths. Improves cross-platform compatibility in temp directory management and binary location.
Adds support for downloading and embedding remote images (http/https URLs) in markdown, enhancing content integration. Provides fallback mechanism with placeholder text upon download failure.
Replace complex heuristic with precise pattern matching for absolute paths:
- Unix paths: starts with /
- Windows drive letters: C:\ or C:/ using regex /^[a-zA-Z]:[/\\]/
- Windows UNC paths: \\server\share
Removes unreliable temp/tmp path indicators and file: URL checks while
maintaining fs fallback behavior for proper external file processing.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix pathUtils.fileExists() to handle absolute filesystem paths
- Add proper conversion from absolute to vault-relative paths
- Add fs fallback for external files outside vault
- Resolves 'File not found' errors for embedded PDF, image, and document files
- Maintains compatibility with both vault-relative and absolute paths
This fixes the path resolution issue that occurred after migrating to vault.adapter,
where embedded files were showing as 'not found' because absolute paths were being
passed to vault.adapter.exists() which only accepts vault-relative paths.
- Add ABOUTME comments following guidelines
- Implement safe FileSystemAdapter access with proper type checking
- Use vault.adapter methods (exists, mkdir, list, remove)
- Use normalizePath() consistently for all paths
- Match existing patterns (cleanupDir only removes files, returns boolean)
- Add user-friendly error messages with Notice
- Place in src/core/ alongside other core utilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>