0chain / gosdk

A client SDK in Go to interface the blockchain and storage platform, and other smart contracts
MIT License
32 stars 29 forks source link

createdir command on windows #392

Closed Kishan-Dhakan closed 2 years ago

Kishan-Dhakan commented 2 years ago

Using ./zbox createdir --allocation $alloc --dirname "/roor/nested" followed by list-all on Ubuntu shows expected output:

[{"name":"root","path":"/root","type":"d","size":0,"hash":""},{"name":"nested","path":"/root/nested","type":"d","size":0,"hash":""}]

But same command on windows followed by list-all shows this output (only one directory as opposed to two directories, one nested inside the other):

[{"name":"\\roor\\nested","path":"/\\roor\\nested","type":"d","size":0,"hash":""}]
lpoli commented 2 years ago

[{"name":"\\roor\\nested","path":"/\\roor\\nested","type":"d","size":0,"hash":""}]

roor ??

Kishan-Dhakan commented 2 years ago

[{"name":"\\roor\\nested","path":"/\\roor\\nested","type":"d","size":0,"hash":""}]

roor ??

@lpoli it could be any user input name.

The error has changed now, but issue still exists:

On Ubuntu this command: ./zbox createdir --allocation 67791a5a675e945ce026c061b3294a1287f62869f65d6ac13f2cc20a173862ab --dirname "/root/nested" shows "/root/nested directory created".

On Windows, the same command: ./zbox createdir --allocation 67791a5a675e945ce026c061b3294a1287f62869f65d6ac13f2cc20a173862ab --dirname "/root/nested" shows:

0box-sdk        [ERROR]  2022/05/08 17:13:27.571089 dirworker.go:93: https://dev.0chain.net/blobber01Response: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:27.571740 dirworker.go:39: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:27.906549 dirworker.go:93: https://dev.0chain.net/blobber05Response: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:27.909690 dirworker.go:39: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:28.120789 dirworker.go:93: https://dev.0chain.net/blobber04Response: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:28.125201 dirworker.go:39: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:28.126321 dirworker.go:93: https://dev.0chain.net/blobber03Response: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
0box-sdk        [ERROR]  2022/05/08 17:13:28.126899 dirworker.go:39: {"code":"invalid_path","error":"invalid_path: \\root\\nested is not absolute path"}
cnlangzi commented 2 years ago

@Kishan-Dhakan do you run it on cmd.exe, bash.exe or powershell.exe? syntax is different. I guess it should be same as linux on bash.exe and powershell.exe.

Kishan-Dhakan commented 2 years ago

@cnlangzi it still happens in powershell.exe too.

[ERROR]  2022/06/05 15:59:49.769142 dirworker.go:93: https://dev-1.devnet-0chain.net/blobber03Response: {"code":"invalid_path","error":"invalid_path: 
\\dir1\\dir2 is not absolute path"}
0box-sdk        [ERROR]  2022/06/05 15:59:49.773713 dirworker.go:39: {"code":"invalid_path","error":"invalid_path: \\dir1\\dir2 is not absolute path"}
0box-sdk        [ERROR]  2022/06/05 15:59:50.089129 dirworker.go:93: https://dev-1.devnet-0chain.net/blobber06Response: {"code":"invalid_path","error":"invalid_path: 
\\dir1\\dir2 is not absolute path"}
0box-sdk        [ERROR]  2022/06/05 15:59:50.092076 dirworker.go:39: {"code":"invalid_path","error":"invalid_path: \\dir1\\dir2 is not absolute path"}
Kishan-Dhakan commented 2 years ago

@cnlangzi I've fixed it on https://github.com/0chain/gosdk/pull/478. Did local sanity testing on windows powershell:

./zbox createdir --allocation $alloc--dirname "\dir3\dir4" and `./zbox createdir --allocation $alloc--dirname "/dir3/dir4" both create a dir successfully. Please review once, thanks.