FilePath.createDirectoryIdempotent()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 10
Description
| @zooko reported | |
|---|---|
| Trac ID | trac#5280 |
| Type | enhancement |
| Created | 2011-09-28 06:55:41Z |
In the Tahoe-LAFS project we sometimes want to create a directory if it isn't already there, and we don't want to get an exception if there is a race condition so that the directory get created by some other process at the same moment our process is trying to create it. Therefore we use this utility function fileutil.make_dirs.
Here is a patch which adds FilePath.createDirectoryIdempotent and FilePath.makedirsIdempotent. The implementation in this patch is superior to the one in fileutil.make_dirs because this one will correctly propagate an exception (for example, Permission Denied or some random exception due to your disk dying) even if there is a directory existing at that point.
This patch includes detailed tests which I hope sufficiently illustrate why the implementations of these two methods are the way they are.
This patch is based on top of the patch already posted to [#5279](https://github.com/twisted/twisted/issues/5279). If #5279 is not already reviewed then you'll need to review it as well to review this.
Thank you!
Attachments:
- createDirectoryIdempotent.diff (11031 bytes) - added by zooko on 2011-09-28 06:55:54Z -
Searchable metadata
trac-id__5280 5280
type__enhancement enhancement
reporter__zooko zooko
priority__normal normal
milestone__
branch__
branch_author__
status__new new
resolution__None None
component__core core
keywords__
time__1317192941000000 1317192941000000
changetime__1317408891000000 1317408891000000
version__None None
owner__zooko zooko
cc__zooko
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the attached createDirectoryIdempotent.diff and issue #5279 first, then inspect allmydata/util/fileutil.py and the FilePath methods it extends. Confirm that the detailed tests cover concurrent directory creation and that exceptions such as permission errors still propagate; done means the proposed methods and tests are integrated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100