Browse Source

Merge pull request #2615 from calmh/jsonvv

Humanize serialization of version vectors
Audrius Butkevicius 10 years ago
parent
commit
a2833d18ed
1 changed files with 6 additions and 1 deletions
  1. 6 1
      cmd/syncthing/gui.go

+ 6 - 1
cmd/syncthing/gui.go

@@ -10,6 +10,8 @@ import (
 	"bytes"
 	"compress/gzip"
 	"crypto/tls"
+	"encoding/base32"
+	"encoding/binary"
 	"encoding/json"
 	"fmt"
 	"io/ioutil"
@@ -1138,8 +1140,11 @@ type jsonVersionVector protocol.Vector
 
 func (v jsonVersionVector) MarshalJSON() ([]byte, error) {
 	res := make([]string, len(v))
+	bs := make([]byte, 8)
 	for i, c := range v {
-		res[i] = fmt.Sprintf("%d:%d", c.ID, c.Value)
+		binary.BigEndian.PutUint64(bs, c.ID)
+		id := base32.StdEncoding.EncodeToString(bs)
+		res[i] = fmt.Sprintf("%s:%d", id[:7], c.Value)
 	}
 	return json.Marshal(res)
 }