Skip to content

Implement folder merge functionality#17

Open
ggfevans wants to merge 1 commit intomfarr:mainfrom
ggfevans:feature/issue-5-folder-merge
Open

Implement folder merge functionality#17
ggfevans wants to merge 1 commit intomfarr:mainfrom
ggfevans:feature/issue-5-folder-merge

Conversation

@ggfevans
Copy link
Copy Markdown
Contributor

Fixes #5

Summary

Implements smart folder merging when archiving a folder that already exists in the archive destination.

Changes

  • Prompts user to merge when archiving folder with existing destination
  • Compares file contents byte-by-byte before replacing
  • Skips identical files to preserve existing versions
  • Replaces only files with different content
  • Tracks detailed merge statistics (added, replaced, skipped, failed)
  • Handles individual file errors gracefully without stopping merge
  • Only deletes source folder when completely empty

Implementation Details

  • Iterates over copy of children array to prevent modification-during-iteration issues
  • Uses app.vault.read() for content comparison
  • Reports detailed statistics in success message
  • Lists failed files if any errors occur
  • Prevents ENOTEMPTY errors with empty-folder check before deletion

Testing

Tested with mixed-content folders containing:

  • Identical files (skipped correctly)
  • Modified files (replaced correctly)
  • New files (added correctly)

All merge operations completed successfully with proper statistics reporting.

- Add smart merge when archiving folders with existing destination
- Compare file contents before replacing (byte-level comparison)
- Skip identical files, replace only when content differs
- Track merge statistics (added, replaced, skipped, failed)
- Handle errors gracefully without stopping entire merge
- Only delete source folder when completely empty

Fixes mfarr#5
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.

Merge folder contents if archiving a folder that already exists in the archive

1 participant