function checkRepositoryAndConfiguration (ipfsd) {
  if (!fs.pathExistsSync(ipfsd.path)) {
    // If the repository doesn't exist, skip verification.
    return true
  }

  try {
    const stats = fs.statSync(ipfsd.path)
    if (!stats.isDirectory()) {
      logger.error(`${ipfsd.path} must be a directory`)
      dialogs.repositoryMustBeDirectoryDialog(ipfsd.path)
      return false
    }

    if (!apiFileExists(ipfsd)) {
      if (!configExists(ipfsd)) {
        // Config is generated automatically if it doesn't exist.
        logger.error(`configuration does not exist at ${ipfsd.path}`)
        dialogs.repositoryConfigurationIsMissingDialog(ipfsd.path)
        return true
      }

      // This should catch errors such having no configuration file,
      // IPFS_DIR not being a directory, or the configuration file
      // being corrupted.
      readConfigFile(ipfsd)
    }

    const swarmKeyPath = join(ipfsd.path, 'swarm.key')
    if (fs.pathExistsSync(swarmKeyPath)) {
      // IPFS Desktop does not support private network IPFS repositories.
      dialogs.repositoryIsPrivateDialog(ipfsd.path)
      return false
    }

    return true
  } catch (e) {
    // Save to error.log
    logger.error(e)
    dialogs.repositoryIsInvalidDialog(ipfsd.path)
    return false
  }
}
Checks if the repository and the configuration file are valid.

@param {import('ipfsd-ctl').Controller} ipfsd
@returns {boolean}