Skip to content

Conversation

kiminuo
Copy link
Contributor

@kiminuo kiminuo commented Feb 1, 2021

This PR makes it easier in #20744 to remove our dependency on the boost::filesystem::unique_path() function which does not have a direct equivalent in C++17.

This PR attempts to re-implement boost::filesystem::unique_path() as GetUniquePath(path) but the implementations are not meant to be the same.

Note:

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 1, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@fanquake fanquake requested a review from ryanofsky February 2, 2021 05:48
@fanquake fanquake changed the title [draft] refactor: Replace fs::unique_path with GetUniquePath(path) calls refactor: Replace fs::unique_path with GetUniquePath(path) calls Feb 2, 2021
@laanwj
Copy link
Member

laanwj commented Feb 2, 2021

Concept ACK

However, this introduces a circular dependency right now:

A new circular dependency in the form of "fs -> random -> logging -> fs" appears to have been introduced.

@kiminuo kiminuo force-pushed the feature/fs-unique-path branch from f83bb3a to 805f888 Compare February 2, 2021 23:02
BOOST_CHECK_EQUAL(tmpfolder, p3.parent_path());

// Ensure that generated paths are actually different.
BOOST_CHECK(p1 != p2);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left this intentionally very simple. One can certainly come up with many different ways to make this more robust but I would like to solicit for feedback for this.

@kiminuo
Copy link
Contributor Author

kiminuo commented Feb 3, 2021

However, this introduces a circular dependency right now:

I have changed the implementation. So this is fixed.

@kiminuo kiminuo marked this pull request as ready for review February 3, 2021 10:18
…tem::unique_path() which is not available in std::filesystem.
@kiminuo kiminuo force-pushed the feature/fs-unique-path branch from 0e1b085 to 1bca2aa Compare February 4, 2021 10:38
@practicalswift
Copy link
Contributor

Concept ACK

Thanks for paving the way for further Boost removal!

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 1bca2aa. It's a simple change and extra test coverage is nice

}

BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem." (1bca2aa)

Not a problem but there is an extraneous whitespace change here

@laanwj
Copy link
Member

laanwj commented Feb 9, 2021

Code review ACK 1bca2aa

@laanwj laanwj merged commit d202054 into bitcoin:master Feb 9, 2021
@kiminuo kiminuo deleted the feature/fs-unique-path branch February 9, 2021 21:24
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 11, 2021
…Path(path) calls

1bca2aa Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem. (Kiminuo)

Pull request description:

  This PR makes it easier in bitcoin#20744 to remove our dependency on the `boost::filesystem::unique_path()` function which does not have a direct equivalent in C++17.

  This PR attempts to re-implement `boost::filesystem::unique_path()` as `GetUniquePath(path)` but the implementations are not meant to be the same.

  Note:

  * Boost 1.75.0 implementation of `unique_path`: https://github.com/boostorg/filesystem/blob/9cab675b71e98706886a87afe7c19eb9da568961/src/unique_path.cpp#L235

  * In the previous implementation, I attempted to add:
      ```cpp
      fs::path GetUniquePath(const fs::path& base)
      {
          FastRandomContext rnd;
          fs::path tmpFile = base / HexStr(rnd.randbytes(8));
          return tmpFile;
      }
      ```

      to `fs.cpp` but this leads to a circular dependency: "fs -> random -> logging -> fs". That is why the modified implementation adds a new file.

ACKs for top commit:
  laanwj:
    Code review ACK 1bca2aa
  ryanofsky:
    Code review ACK 1bca2aa. It's a simple change and extra test coverage is nice

Tree-SHA512: f324bdf0e254160c616b5033c3ece33d87db23eb0135acee99346ade7b5cf0d30f3ceefe359a25a8e9b53ba8e4419f459c2bdd369e10fc0152ce95031d1f221c
kwvg added a commit to kwvg/dash that referenced this pull request Jul 2, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 4, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 9, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 9, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 9, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 13, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 13, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 13, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 15, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 15, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 16, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 1, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 5, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 5, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 5, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 9, 2021
5tefan pushed a commit to 5tefan/dash that referenced this pull request Aug 12, 2021
fanquake added a commit to fanquake/bitcoin that referenced this pull request Sep 8, 2021
maflcko pushed a commit that referenced this pull request Sep 8, 2021
69a439b doc: add missing copyright header to getuniquepath.cpp (fanquake)

Pull request description:

  This was missed in #21052.

ACKs for top commit:
  hebasto:
    ACK 69a439b, but a scripted-diff using `copyright_header.py insert` looks preferable.

Tree-SHA512: 1a75ffd93fa8e5e83821e1fe984353422740ebf9e203dc873debf4dffec0e23f55a1e31f806dd2d66087d3620f6dc447af69f9124f0bcc6676ef91ee35374832
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 11, 2021
…th.cpp

69a439b doc: add missing copyright header to getuniquepath.cpp (fanquake)

Pull request description:

  This was missed in bitcoin#21052.

ACKs for top commit:
  hebasto:
    ACK 69a439b, but a scripted-diff using `copyright_header.py insert` looks preferable.

Tree-SHA512: 1a75ffd93fa8e5e83821e1fe984353422740ebf9e203dc873debf4dffec0e23f55a1e31f806dd2d66087d3620f6dc447af69f9124f0bcc6676ef91ee35374832
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Mar 13, 2022
…th.cpp

69a439b doc: add missing copyright header to getuniquepath.cpp (fanquake)

Pull request description:

  This was missed in bitcoin#21052.

ACKs for top commit:
  hebasto:
    ACK 69a439b, but a scripted-diff using `copyright_header.py insert` looks preferable.

Tree-SHA512: 1a75ffd93fa8e5e83821e1fe984353422740ebf9e203dc873debf4dffec0e23f55a1e31f806dd2d66087d3620f6dc447af69f9124f0bcc6676ef91ee35374832
gades pushed a commit to cosanta/cosanta-core that referenced this pull request May 1, 2022
gades pushed a commit to cosanta/cosanta-core that referenced this pull request May 1, 2022
…th.cpp

69a439b doc: add missing copyright header to getuniquepath.cpp (fanquake)

Pull request description:

  This was missed in bitcoin#21052.

ACKs for top commit:
  hebasto:
    ACK 69a439b, but a scripted-diff using `copyright_header.py insert` looks preferable.

Tree-SHA512: 1a75ffd93fa8e5e83821e1fe984353422740ebf9e203dc873debf4dffec0e23f55a1e31f806dd2d66087d3620f6dc447af69f9124f0bcc6676ef91ee35374832
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants