CPChain / chain

Mirror of https://bitbucket.org/cpchain/chain
GNU General Public License v3.0
51 stars 10 forks source link

Compact database commands create unwanted subdirectories #97

Closed hvredevoort closed 4 years ago

hvredevoort commented 4 years ago

Where does the bug occur? [e.g. the chain, the wallet, the explorer] chain

What is your wallet address and your balance? If it is too private to answer, you can skip it. irrelevant

Describe the bug When the following command is given in this or other variations: ./cpchain chain delete dpor- --datadir ~/.cpchain ./cpchain chain delete dpor- --datadir ~/cpchain ./cpchain chain delete dpor- --datadir /home/username/cpchain ./cpchain chain delete dpor- --datadir /home/username/cpchain/datadir ./cpchain chain delete dpor- --datadir /home/username/cpchain/datadir/chaindata

it creates several different directories like cpchain, keystore, chaindata below the ./datadir directory or other directories depending on what parameter is used. If the default is used with ~/.cpchain it also creates these directories below that directory. If you then issue du -h --total it will have no permission to read those directories.

To Reproduce Steps to reproduce the behavior, and the commands you use. Try several parameters for --datadir ./cpchain chain delete dpor- --datadir ~/.cpchain ./cpchain chain delete dpor- --datadir ~/cpchain ./cpchain chain delete dpor- --datadir /home/username/cpchain ./cpchain chain delete dpor- --datadir /home/username/cpchain/datadir ./cpchain chain delete dpor- --datadir /home/username/cpchain/datadir/chaindata

Expected behavior I don't expect directories to be created, this is a bug.

Screenshots If applicable, add screenshots to help explain your problem.

Configuration (please complete the following information):

Additional context Add any other context about the problem here. If your bug can only be reproduced occasionally, please emphasize it.

hvredevoort commented 4 years ago

Please test this thoroughly as it can really mess up your RNode. Also provide an example of the correct --datadir parameter if the cpchain program is in ~/cpchain and datadir is below ~/cpchain

alex031029 commented 4 years ago

Your report confused me a lot. I called the guy that developed the compact feature, and we reviewed this issue, and currently have no idea why it was that messy and why you had no permission of these subdirectories.

We will try to reproduce your issue, and figure it out.

alex031029 commented 4 years ago

Ah, I got it. The reason why your subdirectories are messy is that the --datadir flag is referring to whole cpchain directory which includes keystore and cpchain etc. Here I attached the directory structure of my computer.

image

If --datadir is not referring the whole cpchain directory (as in my case, the /home/shi/.cpchain), the compact command will create subdirectories like cpchain and keystore under it.

I am not sure if I have explained it clearly.

hvredevoort commented 4 years ago

The issue is that it creates directories when it shouldn’t If you try a few variations (because the documentation is unclear), these same empty directories are created in multiple locations.

alex031029 commented 4 years ago

Ah, I second what you said above. The compact commands is not poka-yoke enough. We may restrict the usage of the command by giving a default value of delete dpor- flag.