2018-08-29 22:59:29 +00:00
|
|
|
#include "command.hh"
|
2018-08-30 23:01:59 +00:00
|
|
|
#include "serve-protocol.hh"
|
2018-08-29 22:59:29 +00:00
|
|
|
#include "shared.hh"
|
|
|
|
#include "store-api.hh"
|
2018-08-30 21:42:28 +00:00
|
|
|
#include "worker-protocol.hh"
|
2018-08-29 22:59:29 +00:00
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
2018-08-30 21:42:28 +00:00
|
|
|
std::string formatProtocol(unsigned int proto)
|
|
|
|
{
|
|
|
|
if (proto) {
|
|
|
|
auto major = GET_PROTOCOL_MAJOR(proto) >> 8;
|
|
|
|
auto minor = GET_PROTOCOL_MINOR(proto);
|
|
|
|
return (format("%1%.%2%") % major % minor).str();
|
|
|
|
}
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2018-08-29 22:59:29 +00:00
|
|
|
struct CmdDoctor : StoreCommand
|
|
|
|
{
|
|
|
|
std::string name() override
|
|
|
|
{
|
|
|
|
return "doctor";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string description() override
|
|
|
|
{
|
|
|
|
return "check your system for potential problems";
|
|
|
|
}
|
|
|
|
|
|
|
|
void run(ref<Store> store) override
|
|
|
|
{
|
|
|
|
std::cout << "Store uri: " << store->getUri() << std::endl;
|
2018-08-30 21:42:28 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
checkStoreProtocol(store->getProtocol());
|
|
|
|
}
|
|
|
|
|
2018-08-30 23:01:59 +00:00
|
|
|
void checkStoreProtocol(unsigned int storeProto) {
|
|
|
|
auto clientProto = GET_PROTOCOL_MAJOR(SERVE_PROTOCOL_VERSION) == GET_PROTOCOL_MAJOR(storeProto)
|
|
|
|
? SERVE_PROTOCOL_VERSION
|
|
|
|
: PROTOCOL_VERSION;
|
|
|
|
|
|
|
|
if (clientProto != storeProto) {
|
2018-08-30 21:42:28 +00:00
|
|
|
std::cout << "Warning: protocol version of this client does not match the store." << std::endl;
|
|
|
|
std::cout << "While this is not necessarily a problem it's recommended to keep the client in" << std::endl;
|
|
|
|
std::cout << "sync with the daemon." << std::endl;
|
|
|
|
std::cout << std::endl;
|
2018-08-30 23:01:59 +00:00
|
|
|
std::cout << "Client protocol: " << formatProtocol(clientProto) << std::endl;
|
|
|
|
std::cout << "Store protocol: " << formatProtocol(storeProto) << std::endl;
|
2018-08-30 21:42:28 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
}
|
2018-08-29 22:59:29 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static RegisterCommand r1(make_ref<CmdDoctor>());
|