Skip to content

fix: resolve startup crash in saveVaultRepoConfig and remove debug logging - #29

Merged
rhoades-brown merged 1 commit into
mainfrom
fix/startup-crash-and-debug-cleanup
Aug 29, 2026
Merged

fix: resolve startup crash in saveVaultRepoConfig and remove debug logging#29
rhoades-brown merged 1 commit into
mainfrom
fix/startup-crash-and-debug-cleanup

Conversation

@rhoades-brown

@rhoades-brown rhoades-brown commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a startup crash in saveVaultRepoConfig() that prevented additional repository ignore patterns from being applied, causing files from sub-folders (e.g. shared/) to leak into the primary repository during sync. Also removes temporary debug logging that was added to diagnose the issue.

Problem

During early Obsidian startup, vault.getAbstractFileByPath() returns null because the vault index hasn't finished loading. The code fell through to vault.create(), which threw "File already exists" because the file was already on disk. This error disrupted the plugin initialization chain before initializeAdditionalRepos() could call configure() with the ignore patterns — so sub-folder files were incorrectly synced to the main repo.

Changes

main.ts

  • Fixed saveVaultRepoConfig(): When the vault index hasn't loaded the file yet, falls back to adapter.exists() / adapter.write() instead of blindly calling vault.create().
  • Early return: Skip file write entirely when there are no vault configs to persist.
  • Removed debug logging: Removed 4 console.log('[DEBUG]') statements added during investigation.

src/services/syncService.ts

  • Removed debug logging: Removed 7 console.log('[DEBUG]') statements from configure(), buildLocalIndex(), and shouldIgnore().

Testing

  • Verified build passes (npm run build)
  • Manual testing: Obsidian reloads without the "File already exists" error, ignore patterns are applied correctly, and sub-folder files no longer appear as additions to the main repo.

@rhoades-brown
rhoades-brown merged commit 2ee9628 into main Aug 29, 2026
5 checks passed
@rhoades-brown
rhoades-brown deleted the fix/startup-crash-and-debug-cleanup branch August 29, 2026 20:44
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