Skip to content

Conversation

@nullable-eth
Copy link
Owner

@nullable-eth nullable-eth commented Aug 1, 2025

Pull Request Description

🐛 Bug Fixes & Improvements

Fixed JSON Unmarshaling Error for TV Shows

  • Issue: Plex API sometimes returns subtitleMode as string instead of integer, causing parsing failures
  • Solution: Created FlexibleInt type that handles both string and integer values
  • Impact: Resolves sync failures for TV shows with user set values at the tv show level (change subtitle display for specific tv show)

Fixed Redundant Transfer Method Logging

  • Issue: Duplicate "High-performance file transfer enabled" messages in logs
  • Solution: Removed redundant log from orchestrator, kept transfer-specific logging in transfer module
  • Impact: Cleaner, more focused log output

Simplified Environment Variable Names

  • Issue: SSH variables had inconsistent OPT_ prefixes
  • Solution: Standardized to SSH_USER, SSH_PASSWORD, SSH_PORT, SSH_KEY_PATH
  • Impact: More intuitive configuration, updated documentation and examples

Enhanced Path Mapping for Same-Volume Mounting

  • Issue: Path mapping failed when mounting same volumes as Plex server
  • Solution: Improved logic to handle scenarios where SOURCE_REPLACE_TO is empty
  • Implementation:
    # New: Same-volume mounting support
    SOURCE_REPLACE_FROM: "/data/Media"  # Strip this prefix
    SOURCE_REPLACE_TO: ""               # Empty = use Plex paths as-is  
    DEST_ROOT_DIR: "/mnt/storage"       # Destination root
  • Result: /data/Media/Movies/Action/movie.mkv/mnt/storage/Movies/Action/movie.mkv

Fixed File Transfer Issues with Special Characters

  • Issue: SCP/rsync failed on files with apostrophes and special characters
  • Root Causes:
    1. SCP wasn't using sshpass for password authentication
    2. Incorrect shell escaping in exec.Command usage
  • Solutions:
    1. Properly implemented sshpass wrapper for password auth
    2. Removed shell quotes (Go's exec.Command handles argument separation automatically)
  • Impact: Files like Miller's Girl (2024).mp4 and The Internet's Own Boy.mkv now transfer successfully

📚 Documentation Updates

  • Updated README with new environment variable names
  • Added sshpass requirement for password authentication
  • Documented same-volume mounting configuration examples
  • Clarified path mapping behavior and use cases

🔧 Technical Details

New Types:

type FlexibleInt struct {
    Value int
}
// Handles both string and integer JSON values

Enhanced Path Mapping Logic:

  • Supports traditional path replacement: SOURCE_REPLACE_FROM + SOURCE_REPLACE_TO
  • Supports same-volume mounting: SOURCE_REPLACE_FROM + empty SOURCE_REPLACE_TO
  • Backward compatible with existing configurations

Transfer Method Improvements:

  • Proper sshpass integration for both SCP and rsync
  • Correct argument handling for exec.Command
  • Enhanced error logging and debugging

Testing

  • All builds pass successfully
  • Path mapping tested with complex scenarios
  • Environment variable changes validated
  • Transfer methods verified for special character handling

🚀 Benefits

  • Reliability: Eliminates sync failures from JSON parsing and special characters
  • Flexibility: Supports multiple volume mounting strategies
  • Usability: Simplified configuration with cleaner environment variables
  • Maintainability: Reduced redundant logging and improved error handling

Breaking Changes:

  • Environment variables: OPT_SSH_*SSH_* (documented migration path provided)

Compatibility:

  • All existing path mapping configurations continue to work
  • New same-volume mounting is opt-in via configuration

@nullable-eth nullable-eth merged commit a802e5b into main Aug 1, 2025
4 checks passed
@nullable-eth nullable-eth deleted the fix-transfers branch August 1, 2025 14:49
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.

2 participants