Skip to content

Commit d555768

Browse files
committed
remote: handshake - use minimumCommonVersion of our vs daemon protoVersion
1 parent 14f93bf commit d555768

File tree

1 file changed

+7
-9
lines changed
  • hnix-store-remote/src/System/Nix/Store/Remote

1 file changed

+7
-9
lines changed

hnix-store-remote/src/System/Nix/Store/Remote/Client.hs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ runStoreSocket preStoreConfig code =
114114

115115
sockPutS protoVersion ourProtoVersion
116116

117-
when (daemonVersion >= ProtoVersion 1 14)
117+
let minimumCommonVersion = min daemonVersion ourProtoVersion
118+
119+
when (minimumCommonVersion >= ProtoVersion 1 14)
118120
$ sockPutS int (0 :: Int) -- affinity, obsolete
119121

120-
when (daemonVersion >= ProtoVersion 1 11) $ do
122+
when (minimumCommonVersion >= ProtoVersion 1 11) $ do
121123
sockPutS
122124
(mapErrorS RemoteStoreError_SerializerPut bool)
123125
False -- reserveSpace, obsolete
124126

125-
-- not quite right, should be min of the two
126-
-- as well as two ^ above
127-
when (ourProtoVersion >= ProtoVersion 1 33) $ do
127+
when (minimumCommonVersion >= ProtoVersion 1 33) $ do
128128
-- If we were buffering I/O, we would flush the output here.
129129
_daemonNixVersion <-
130130
sockGetS
@@ -133,7 +133,7 @@ runStoreSocket preStoreConfig code =
133133
text
134134
return ()
135135

136-
_remoteTrustsUs <- if ourProtoVersion >= ProtoVersion 1 35
136+
_remoteTrustsUs <- if minimumCommonVersion >= ProtoVersion 1 35
137137
then do
138138
sockGetS
139139
$ mapErrorS RemoteStoreError_SerializerHandshake trustedFlag
@@ -146,6 +146,4 @@ runStoreSocket preStoreConfig code =
146146
(\(PreStoreConfig a b) -> StoreConfig a ourProtoVersion b)
147147
processOutput
148148

149-
-- TODO should be minimum of
150-
-- ourProtoVersion vs daemonVersion
151-
pure ourProtoVersion
149+
pure minimumCommonVersion

0 commit comments

Comments
 (0)