How to check if a folder is a database folder and if it's already open?

  1. If a folder contains a valid badgerDB?
    Valid badger db could mean a lot of things. It could mean that all SST files are valid. It could mean all SST files are present. It could mean various different metadata files are valid and present. I am not sure all of these things could be verified.
    But in general, I can suggest that you can read the MANIFEST file. (It’s a binary file, so you will have to write code). Manifest file is supposed to contain list of the SST files. Then you can check if all the SST files are present.
  2. If it is already open
    If a badger db is using it, then you will see a LOCK file in the folder.