Skip to content

Commit a09e2d8

Browse files
committed
filesync: mark if options have been encoded to detect old versions
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 9d491e7 commit a09e2d8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

session/filesync/filesync.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
io "io"
77
"net/url"
88
"os"
9+
"strconv"
910
"strings"
1011
"unicode"
1112

@@ -26,6 +27,7 @@ const (
2627
keyFollowPaths = "followpaths"
2728
keyDirName = "dir-name"
2829
keyExporterMetaPrefix = "exporter-md-"
30+
keyOptsEncoded = "opts-encoded"
2931
)
3032

3133
type fsSyncProvider struct {
@@ -84,7 +86,17 @@ func (sp *fsSyncProvider) handle(method string, stream grpc.ServerStream) (retEr
8486
}
8587

8688
opts, _ := metadata.FromIncomingContext(stream.Context()) // if no metadata continue with empty object
87-
opts = decodeOpts(opts)
89+
90+
isDecoded := false
91+
if v, ok := opts[keyOptsEncoded]; ok && len(v) > 0 {
92+
if b, _ := strconv.ParseBool(v[0]); b {
93+
isDecoded = true
94+
}
95+
}
96+
97+
if isDecoded {
98+
opts = decodeOpts(opts)
99+
}
88100

89101
dirName := ""
90102
name, ok := opts[keyDirName]
@@ -212,6 +224,9 @@ func FSSync(ctx context.Context, c session.Caller, opt FSSendRequestOpt) error {
212224

213225
var stream grpc.ClientStream
214226

227+
// mark that we have encoded options so older versions with raw values can be detected on client side
228+
opts[keyOptsEncoded] = []string{"1"}
229+
215230
opts = encodeOpts(opts)
216231

217232
ctx = metadata.NewOutgoingContext(ctx, opts)

0 commit comments

Comments
 (0)