[DOCS-9481] Docs for SERVER-25839: shell mkdir should return whether a new directory was created Created: 02/Dec/16  Updated: 22/Feb/17  Resolved: 14/Feb/17

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Emily Hall Assignee: Steve Renaker (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-25839 shell mkdir should return whether a n... Closed
Participants:
Days since reply: 6 years, 51 weeks, 6 days ago

 Description   

Engineering Ticket Description:

The shell's mkdir() function is a wrapper around boost::filesystem::create_directories(). This function returns a bool indicating whether or not a new directory was created. However, the shell's mkdir throws away this return status, and instead always returns true (which is useless).

This makes it impossible for shell code to determine whether a new directory has been created or not. This would be helpful for jstest code that needs to atomically create a new directory of its own, so that it can work inside that directory without worrying about other concurrent runs of the jstest, etc.

The new return status should satisfy:

  • Truthy on success, so that existing code which (erroneously) checks the result of mkdir() still works.
  • User understandability. Currently users see

    > mkdir("foo")
    true
    

    which will be presumed to mean "okay, that has been done". The return value should be similarly understandable "at first glance".

Simply returning the bool from boost::filesystem::create_directories() fails both of these requirements. Better would be to return an object such as

> mkdir("foo")
{ exists: true, created: true }
> mkdir("foo")
{ exists: true, created: false }

where the exists field is always true, indicating that the directory now exists (because if there was an error, an assertion would have been thrown), and the created field contains the result from create_directories (ie. whether or not a directory was actually created in response to this mkdir(), or whether the directory was pre-existing).



 Comments   
Comment by Githook User [ 16/Feb/17 ]

Author:

{u'username': u'steveren', u'name': u'Steve Renaker', u'email': u'steve.renaker@mongodb.com'}

Message: DOCS-9481: shell mkdir should return whether a new directory was created

Signed-off-by: kay <kay.kim@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/32a8da5eb2507e15e6c13521c5dbadbad39b7a4b

Generated at Thu Feb 08 07:58:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.