From 246acf93f2b61b2915e2140d761b19c2e836a96e Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Fri, 31 Aug 2018 01:01:59 +0200 Subject: [PATCH] nix doctor: handle serve protocol The serve protocol used by LegacySSHStore has a different major and shouldn't be compared to PROTOCOL_VERSION. --- src/nix/doctor.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nix/doctor.cc b/src/nix/doctor.cc index 6ef5eb9d3..a31df595d 100644 --- a/src/nix/doctor.cc +++ b/src/nix/doctor.cc @@ -1,4 +1,5 @@ #include "command.hh" +#include "serve-protocol.hh" #include "shared.hh" #include "store-api.hh" #include "worker-protocol.hh" @@ -35,14 +36,18 @@ struct CmdDoctor : StoreCommand checkStoreProtocol(store->getProtocol()); } - void checkStoreProtocol(unsigned int proto) { - if (PROTOCOL_VERSION != proto) { + 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) { 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; - std::cout << "Client protocol: " << formatProtocol(PROTOCOL_VERSION) << std::endl; - std::cout << "Store protocol: " << formatProtocol(proto) << std::endl; + std::cout << "Client protocol: " << formatProtocol(clientProto) << std::endl; + std::cout << "Store protocol: " << formatProtocol(storeProto) << std::endl; std::cout << std::endl; } }