Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Print the canonical path of wasm/abi when not found #6346

Merged
merged 2 commits into from
Nov 20, 2018

Conversation

conr2d
Copy link
Contributor

@conr2d conr2d commented Nov 19, 2018

Change Description

Fixes #6343.
This patch makes cleos print the canonical path of wasm or abi when they are not found. Showing the canonical path for contract-dir can help users find out wrong configuration or option set by themselves.

Consensus Changes

None

API Changes

None

Documentation Additions

None

@@ -2468,7 +2468,7 @@ int main( int argc, char** argv ) {
bytes code_bytes;
if(!contract_clear){
std::string wasm;
fc::path cpath(contractPath);
fc::path cpath = fc::canonical(fc::path(contractPath));

if( cpath.filename().generic_string() == "." ) cpath = cpath.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.

This check should be before the conversion to canonical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean "don't call canonical() when given path is already absolute path"? (By check whether the first character of contractPath is . ?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 2473 checks if cpath is "." and if it is then it sets cpath to cpath.parent_path(). If you convert to canonical then cpath will never equal ".".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. Sorry for the stupid question. :)

@@ -2523,7 +2523,7 @@ int main( int argc, char** argv ) {

bytes abi_bytes;
if(!contract_clear){
fc::path cpath(contractPath);
fc::path cpath = fc::canonical(fc::path(contractPath));
if( cpath.filename().generic_string() == "." ) cpath = cpath.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.

Same as above, the check for "." should be before switch to canonical.

@conr2d
Copy link
Contributor Author

conr2d commented Nov 20, 2018

@heifner

if( cpath.filename().generic_string() == "." ) cpath = cpath.parent_path();

I've tested above code, but it just converts path to empty one when given condition is true, so with the current version of cleos, the next command fails:

cleos set contract testaccount1 .

By converting path to canonical one, I found the command cleos set contract testaccount1 . work well, so removed checking . lines.

@heifner heifner merged commit a37d1bd into EOSIO:develop Nov 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants