{"id":21409837,"url":"https://github.com/stackbuilders/atomic-write","last_synced_at":"2025-03-17T16:12:53.367Z","repository":{"id":26958500,"uuid":"30421562","full_name":"stackbuilders/atomic-write","owner":"stackbuilders","description":"Writes files atomically in Haskell while preserving permissions","archived":false,"fork":false,"pushed_at":"2025-02-13T14:04:37.000Z","size":1235,"stargazers_count":19,"open_issues_count":4,"forks_count":2,"subscribers_count":27,"default_branch":"main","last_synced_at":"2025-03-02T13:12:40.488Z","etag":null,"topics":["atomic-actions","file-management","hacktoberfest","haskell"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackbuilders.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-06T16:30:11.000Z","updated_at":"2025-02-14T04:17:53.000Z","dependencies_parsed_at":"2024-01-09T14:31:28.660Z","dependency_job_id":"077627d0-b969-44f9-ae41-672d98879cf0","html_url":"https://github.com/stackbuilders/atomic-write","commit_stats":{"total_commits":52,"total_committers":8,"mean_commits":6.5,"dds":0.5192307692307692,"last_synced_commit":"0a31d7b8ebaadcd73e26f6e9a1aabc1354d64662"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fatomic-write","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fatomic-write/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fatomic-write/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fatomic-write/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackbuilders","download_url":"https://codeload.github.com/stackbuilders/atomic-write/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atomic-actions","file-management","hacktoberfest","haskell"],"created_at":"2024-11-22T17:34:33.251Z","updated_at":"2025-03-17T16:12:53.345Z","avatar_url":"https://github.com/stackbuilders.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://github.com/stackbuilders/atomic-write/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/stackbuilders/atomic-write/actions/workflows/build.yml)\n[![Hackage version](https://img.shields.io/hackage/v/atomic-write.svg)](http://hackage.haskell.org/package/atomic-write)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n# Atomic Write\n\nAtomic Write assists with atomic modification of files using\nHaskell. It is a wrapper for using the atomic mv(1) operation which\ncorrectly sets permissions based on the original file, or on system\ndefaults if no file previously exists.\n\n## How it works\nOn most Unix systems, mv is an atomic operation. This makes it simple to write to a file atomically just by using the mv operation. However, this will destroy the permissions on the original file. This library does the following to preserve permissions while atomically writing to a file:\n\nIf an original file exists, take those permissions and apply them to the temp file before mving the file into place.\n\nIf the original file does not exist, create a following with default permissions (based on the currently-active umask).\n\nThis way, when the file is mv'ed into place, the permissions will be the ones held by the original file.\n\nThis library is based on similar implementations found in common libraries in Ruby and Python:\n\n- [Ruby on Rails includes a similar method called atomic_write](https://apidock.com/rails/File/atomic_write/class)\n\n- [Chef includes atomic update functionality](https://github.com/chef/chef/blob/c4631816132fcfefaba3d123a1d0dfe8bc2866bb/lib/chef/file_content_management/deploy/mv_unix.rb#L23:L71)\n\n- [There is a python library for atomically updating a file](https://github.com/sashka/atomicfile)\n\n## Usage\n\nTo use `atomic-write`, import the module corresponding to the type you wish to write atomically, e.g., to write a (strict) ByteString atomically:\n\n```import System.AtomicWrite.Writer.ByteString```\n\nThen you can use the atomicWriteFile function that accepts a FilePath and a ByteString, e.g.:\n\n```atomicWriteFile myFilePath myByteString```\n\nSee the\n[Haddock documentation](http://hackage.haskell.org/package/atomic-write).\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://www.stackbuilders.com/news/author/justin-leitgeb\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/9977?v=4?s=100\" width=\"100px;\" alt=\"Justin S. Leitgeb\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJustin S. Leitgeb\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/stackbuilders/atomic-write/commits?author=jsl\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/cptrodolfox\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/20303685?v=4?s=100\" width=\"100px;\" alt=\"William R. Arellano\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eWilliam R. Arellano\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/stackbuilders/atomic-write/commits?author=cptrodolfox\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/Alex0jk\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/22301755?v=4?s=100\" width=\"100px;\" alt=\"Alexander Mejía\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlexander Mejía\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/stackbuilders/atomic-write/commits?author=Alex0jk\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/acamino\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/957202?v=4?s=100\" width=\"100px;\" alt=\"Agustin Camino\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAgustin Camino\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/stackbuilders/atomic-write/commits?author=acamino\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://juancarlos.io/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/2164411?v=4?s=100\" width=\"100px;\" alt=\"Juan Paucar\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJuan Paucar\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/stackbuilders/atomic-write/commits?author=juanpaucar\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://www.barbaramorantes.com/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/67979158?v=4?s=100\" width=\"100px;\" alt=\"Barbara Morantes\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBarbara Morantes\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#example-BarbDMC\" title=\"Examples\"\u003e💡\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n  \u003ctfoot\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" size=\"13px\" colspan=\"7\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg\"\u003e\n          \u003ca href=\"https://all-contributors.js.org/docs/en/bot/usage\"\u003eAdd your contributions\u003c/a\u003e\n        \u003c/img\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tfoot\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## License\n\nMIT, see [the LICENSE file](LICENSE).\n\n## Contributing\n\nDo you want to contribute to this project? Please take a look at our [contributing guideline](/docs/CONTRIBUTING.md) to know how you can help us build it.\n\n---\n\u003cimg src=\"https://cdn.stackbuilders.com/media/images/Sb-supports.original.png\" alt=\"Stack Builders\" width=\"50%\"\u003e\u003c/img\u003e\n[Check out our libraries](https://github.com/stackbuilders/) | [Join our team](https://www.stackbuilders.com/join-us/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbuilders%2Fatomic-write","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackbuilders%2Fatomic-write","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbuilders%2Fatomic-write/lists"}