[SERVER-25839] shell mkdir should return whether a new directory was created Created: 29/Aug/16 Updated: 14/Mar/17 Resolved: 30/Sep/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | None |
| Fix Version/s: | 3.4.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Kevin Pulo | Assignee: | Samantha Ritter (Inactive) |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Minor Change | ||||||||
| Sprint: | Platforms 2016-09-19, Platforms 2016-10-10 | ||||||||
| Participants: | |||||||||
| 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:
Simply returning the bool from boost::filesystem::create_directories() fails both of these requirements. Better would be to return an object such as
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 Samantha Ritter (Inactive) [ 30/Sep/16 ] |
|
mkdir now returns more complex output. It can still be evaluated as a boolean like before, but there are now two fields that can provide additional information to the user:
|
| Comment by Githook User [ 30/Sep/16 ] |
|
Author: {u'username': u'samantharitter', u'name': u'samantharitter', u'email': u'samantha.ritter@10gen.com'}Message: |
| Comment by Githook User [ 30/Sep/16 ] |
|
Author: {u'username': u'samantharitter', u'name': u'samantharitter', u'email': u'samantha.ritter@10gen.com'}Message: |