Skip to content

Conversation

@promag
Copy link
Contributor

@promag promag commented Oct 20, 2018

The implementation of fs::relative resolves symlinks which is not intended
in ListWalletDir. The replacement does what is required, and listwalletdir RPC
tests are fixed accordingly.

Also, fs::recursive_directory_iterator iteration is fixed to build with boost 1.47.

Copy link
Member

Choose a reason for hiding this comment

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

please add a unit test for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@DrahtBot
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to reviewers, I've removed the set() because it removes duplicate and that's not the point — w7 was duplicate — sorted() is what's needed.

src/util.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

On Windows, std::filesystem::path("C:\\").parent_path() == std::filesystem::path("C:\\"). It would be an infinity loop. (Only test std::filesystem in MSVC, doesn't test boost::filesystem)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added parent != parent.root_path() condition to the loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

On Windows, std::filesystem::path("C:\").parent_path() == std::filesystem::path("C:\")

Workaround seems ok, but is this is a bug? Both boost filesystem and std::filesystem are supposed to return empty if the path contains a single element:

https://en.cppreference.com/w/cpp/experimental/fs/path/parent_path
https://www.boost.org/doc/libs/1_68_0/libs/filesystem/doc/reference.html#path-parent_path

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@ken2812221 ken2812221 Oct 24, 2018

Choose a reason for hiding this comment

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

I assume this would cause infinity loop on Windows if base / "bar" exist.

GetRelativePath(path, base, base / "bar");

Copy link
Contributor

Choose a reason for hiding this comment

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

Use SetDataDir instead

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 had that but datadir seemed unrelated to this function. I can revert if there is a reason to do that.

The implementation of fs::relative resolves symlinks which is not intended
in ListWalletDir. The replacement does what is required, and listwalletdir
tests are fixed accordingly.

Also, building with boost 1.47 required 2 changes:
 - replace fs::relative with an alternative implementation;
 - fix fs::recursive_directory_iterator iteration.
@promag promag force-pushed the 2018-10-getrelativepath branch from ad779bc to 8697d65 Compare October 24, 2018 10:40
@promag
Copy link
Contributor Author

promag commented Oct 24, 2018

Alternative approach in #14561.

env = nullptr;
} else {
// To avoid accessing a map that has already deconstructed, do not call this when shutdown is true. g_dbenvs.erase would also erase this value.
// TODO: get rid of wild pointers
Copy link
Member

Choose a reason for hiding this comment

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

what are "wild pointers"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is based on #14559, should comment there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually it's #14320

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aka prchain.

@ryanofsky
Copy link
Contributor

Would suggest closing this. I think the fix in #14561 is simpler and more correct.

@promag
Copy link
Contributor Author

promag commented Oct 24, 2018

Agree @ryanofsky.

@promag promag closed this Oct 24, 2018
@promag promag deleted the 2018-10-getrelativepath branch October 24, 2018 14:18
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
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.

7 participants