fix: preserve a distinct backup path for *.original.md inputs#152
Conversation
The new file-compression feature promises automatic backup creation, but `*.original.md` inputs currently collapse the backup path onto the source path and lose the original content. This keeps the common `foo.md -> foo.original.md` behavior unchanged while assigning a distinct backup name for already-suffixed inputs. Constraint: Keep the fix narrow to backup-path generation and one regression test Rejected: Introduce numbered backup discovery logic | larger behavior change than needed for the verified bug Confidence: high Scope-risk: narrow Reversibility: clean Directive: Preserve backup-path distinctness for any future suffix handling changes Tested: npm test -- test/compress-file.test.ts; npm run build Not-tested: Full npm test still hits an unrelated timeout in test/auto-compress.test.ts on this machine
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
PR #150 added automatic backup creation for
memory_compress_file, but there is one filename shape where that contract breaks.For inputs already ending in
*.original.md,resolveBackupPath()returns the same path as the input file, so the function writes the backup and then immediately overwrites that same path with the compressed content.Fix
Keep the existing behavior for ordinary Markdown files:
notes.md->notes.original.mdBut make already-suffixed inputs produce a distinct backup path:
notes.original.md->notes.original.backup.mdThis keeps the diff narrow and preserves the existing naming convention for the common case while making the advertised backup behavior true for
*.original.mdinputs.Verification
npm test -- test/compress-file.test.tsnpm run buildRegression coverage added
New test case:
notes.original.mdwrites its backup tonotes.original.backup.md