Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): add optional flag to utils.writefile() for exclusive writes #893

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

troiganto
Copy link
Contributor

Summary

This PR adds an optional flag to utils.writefile() to enable exclusive writes. Such a write fails if a file with the given name already exists.

The org-attach feature requires functionality like this because it is really adamant about not overwriting attachments that the user might not be aware of. Example here.

Related Issues

Extracted from #878

Slowly getting there …

Changes

  • Add new optional parameter opts to utils.writefile(). Right now, the only option is a boolean flag excl.
  • Add tests for utils.writefile()
  • Add tests for utils.readfile()
  • Also add a tiny test for folds; I was debugging an issue with folding earlier (turns out lazy loading was the culprit) and since there are no tests of folding at all rn, I didn't want to throw it away 🙂

Checklist

I confirm that I have:

  • Followed the Conventional Commits specification (e.g., feat: add new feature, fix: correct bug, docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with make test.
  • Checked for breaking changes and documented them, if any.

Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kristijanhusak kristijanhusak merged commit 500004f into nvim-orgmode:master Feb 6, 2025
6 checks passed
@troiganto troiganto deleted the feat/writefile branch February 6, 2025 08:47
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