Use case: TryCreateDirectory(GetDataDir() / "blocks" / "index") would fail if the blocks directory was not explicitly created before.
The line that did so was in a weird location and could be removed as a result.
Use case: TryCreateDirectory(GetDataDir() / "blocks" / "index") would fail if the blocks directory was not explicitly created before.
The line that did so was in a weird location and could be removed as a result.
The blocks directory is now created here:
https://github.com/benma/bitcoin/blob/de85040fc552178815a71cacb00d16faff994c9a/src/dbwrapper.cpp#L52 via https://github.com/benma/bitcoin/blob/11049f4fe62606d1b0380a9ef800ac130f0fbadf/src/txdb.cpp#L70
and is created the first time it is needed with the initialization of CBlockTreeDB in init.cpp.
utACK
619 | +bool TryCreateDirectories(const boost::filesystem::path& p) 620 | { 621 | try 622 | { 623 | - return boost::filesystem::create_directory(p); 624 | + return boost::filesystem::create_directories(p);
Is this utility function needed at all? I think the definition of fs::create_directories is already exactly what we want here: http://www.boost.org/doc/libs/1_61_0/libs/filesystem/doc/reference.html#create_directories
Returns: true if a new directory was created, otherwise false.
Throws: As specified in Error reporting.
The function is apparently needed, the comment explains why:
/**
* Ignores exceptions thrown by Boost's create_directory if the requested directory exists.
* Specifically handles case where path p exists, but it wasn't possible for the user to
* write to the parent directory.
*/
While I can't recreate this condition, digging up the issue that introduced this talks about some edge cases where it does happen (Truecrypt, ...?): #432
So we should probably leave it.
Ugh. I think not being able to rely on the postcondition is incredibly ugly, and should simply be patched in boost upstream. But okay...
This needs a rebase.
Rebased.
utACK e94c40c770a5de6c95a8c53cfb1717a35c008d83, nice change.
utACK e94c40c770a5de6c95a8c53cfb1717a35c008d83
utACK e94c40c
652 | @@ -653,15 +653,15 @@ bool RenameOver(fs::path src, fs::path dest) 653 | } 654 | 655 | /** 656 | - * Ignores exceptions thrown by Boost's create_directory if the requested directory exists. 657 | + * Ignores exceptions thrown by Boost's create_directories if the requested directory exists.
Since you're touching this line anyways, you could also remove the reference to Boost, which isn't used here anymore (also, the comment at the end of the function could be updated)
But it is using Boost.
namespace fs = boost::filesystem;.
I fixed the comment at the end of the function.
hm, ok. I was under the impression that this was changed in https://github.com/benma/bitcoin/commit/bac5c9cf643e9333479ac667426d0b70f8f3aa7f, but I guess I misread
Use case: TryCreateDirectory(GetDataDir() / "blocks" / "index") would
fail if the blocks directory was not explicitly created before.
The line that did so was in a weird location and could be removed as a
result.