diff --git a/src/watch_voice_memos.py b/src/watch_voice_memos.py index 69823b7..8037318 100755 --- a/src/watch_voice_memos.py +++ b/src/watch_voice_memos.py @@ -9,9 +9,9 @@ from watchdog.events import FileSystemEventHandler class VoiceMemoHandler(FileSystemEventHandler): def __init__(self, voice_memo_dir: Path, transcript_dir: Path, summary_dir: Path): - self.voice_memo_dir = voice_memo_dir - self.transcript_dir = transcript_dir - self.summary_dir = summary_dir + self.voice_memo_dir = voice_memo_dir.resolve() # Store resolved path + self.transcript_dir = transcript_dir.resolve() # Store resolved path + self.summary_dir = summary_dir.resolve() # Store resolved path self.processing_lock = False self.base_dir = Path(__file__).parent.parent @@ -20,7 +20,7 @@ class VoiceMemoHandler(FileSystemEventHandler): return if not event.is_directory: - file_path = Path(event.src_path) + file_path = Path(event.src_path).resolve() # Resolve the event path # Handle new voice memo if file_path.parent == self.voice_memo_dir and file_path.suffix.lower() == '.m4a': @@ -37,7 +37,7 @@ class VoiceMemoHandler(FileSystemEventHandler): return if not event.is_directory: - file_path = Path(event.src_path) + file_path = Path(event.src_path).resolve() # Resolve the event path # Handle modified voice memo if file_path.parent == self.voice_memo_dir and file_path.suffix.lower() == '.m4a': @@ -54,7 +54,7 @@ class VoiceMemoHandler(FileSystemEventHandler): return if not event.is_directory: - file_path = Path(event.src_path) + file_path = Path(event.src_path).resolve() # Resolve the event path # Handle deleted voice memo if file_path.parent == self.voice_memo_dir and file_path.suffix.lower() == '.m4a': @@ -147,9 +147,9 @@ def main(): # Start the observer observer.start() print(f"\nWatching for changes in:") - print(f"- Voice memos: {voice_memo_dir}") - print(f"- Transcripts: {transcript_dir}") - print(f"- Summaries: {summary_dir}") + print(f"- Voice memos: {voice_memo_dir.resolve()}") + print(f"- Transcripts: {transcript_dir.resolve()}") + print(f"- Summaries: {summary_dir.resolve()}") print("\nPress Ctrl+C to stop...") try: diff --git a/watch_macos.sh b/watch_macos.sh index 1ff2dc3..44d8684 100755 --- a/watch_macos.sh +++ b/watch_macos.sh @@ -4,22 +4,26 @@ VOICE_MEMO_DIR="VoiceMemos" TRANSCRIPT_DIR="$VOICE_MEMO_DIR/transcripts" +# Get resolved paths +RESOLVED_VOICE_MEMO_DIR=$(readlink -f "$VOICE_MEMO_DIR") +RESOLVED_TRANSCRIPT_DIR=$(readlink -f "$TRANSCRIPT_DIR") + # Print debug info about symlinks echo "Directory information:" echo "Voice memo dir: $(pwd)/$VOICE_MEMO_DIR" echo "Is symlink: $([ -L "$VOICE_MEMO_DIR" ] && echo "yes" || echo "no")" if [ -L "$VOICE_MEMO_DIR" ]; then - echo "Resolves to: $(readlink -f "$VOICE_MEMO_DIR")" + echo "Resolves to: $RESOLVED_VOICE_MEMO_DIR" fi # Check if directories exist -if [ ! -d "$VOICE_MEMO_DIR" ]; then - echo "Error: $VOICE_MEMO_DIR directory does not exist" +if [ ! -d "$RESOLVED_VOICE_MEMO_DIR" ]; then + echo "Error: $RESOLVED_VOICE_MEMO_DIR directory does not exist" exit 1 fi -if [ ! -d "$TRANSCRIPT_DIR" ]; then - echo "Error: $TRANSCRIPT_DIR directory does not exist" +if [ ! -d "$RESOLVED_TRANSCRIPT_DIR" ]; then + echo "Error: $RESOLVED_TRANSCRIPT_DIR directory does not exist" exit 1 fi @@ -37,14 +41,14 @@ process_transcript() { echo "Starting file watcher..." echo "Watching for changes in:" -echo "- Voice memos: $VOICE_MEMO_DIR" -echo "- Transcripts: $TRANSCRIPT_DIR" +echo "- Voice memos: $RESOLVED_VOICE_MEMO_DIR" +echo "- Transcripts: $RESOLVED_TRANSCRIPT_DIR" echo "Press Ctrl+C to stop..." # Monitor both directories in parallel # -L flag enables following symlinks ( - fswatch -L -o "$VOICE_MEMO_DIR" | while read -r f; do + fswatch -L -o "$RESOLVED_VOICE_MEMO_DIR" | while read -r f; do if [[ "$f" =~ \.m4a$ ]]; then process_voice_memo fi @@ -52,7 +56,7 @@ echo "Press Ctrl+C to stop..." ) & ( - fswatch -L -o "$TRANSCRIPT_DIR" | while read -r f; do + fswatch -L -o "$RESOLVED_TRANSCRIPT_DIR" | while read -r f; do if [[ "$f" =~ \.txt$ ]]; then process_transcript fi