diff options
Diffstat (limited to 'cmd_windows.go')
| -rw-r--r-- | cmd_windows.go | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/cmd_windows.go b/cmd_windows.go index 7df0a9b..dfe137a 100644 --- a/cmd_windows.go +++ b/cmd_windows.go @@ -275,16 +275,42 @@ func scanDirectory(root string, stack *GitignoreStack) *Manifest { } func sendManifest(conn net.Conn, manifest *Manifest) { - msg := &ProtocolMessage{ - Type: "manifest", - Files: manifest.ToJSON(), + const batchSize = 1000 + files := make([]FileMetaJSON, 0, batchSize) + paths := make([]string, 0, batchSize) + + for path, meta := range manifest.ToJSON() { + paths = append(paths, path) + files = append(files, meta) + + if len(files) >= batchSize { + msg := &ProtocolMessage{ + Type: "manifest_batch", + Files: make(map[string]FileMetaJSON), + } + for i, p := range paths { + msg.Files[p] = files[i] + } + data, _ := EncodeMessage(msg) + data = append(data, '\n') + conn.Write(data) + files = files[:0] + paths = paths[:0] + } } - data, err := EncodeMessage(msg) - if err != nil { - return + + if len(files) > 0 { + msg := &ProtocolMessage{ + Type: "manifest_batch", + Files: make(map[string]FileMetaJSON), + } + for i, p := range paths { + msg.Files[p] = files[i] + } + data, _ := EncodeMessage(msg) + data = append(data, '\n') + conn.Write(data) } - data = append(data, '\n') - conn.Write(data) done := &ProtocolMessage{Type: "manifest_done"} doneData, _ := EncodeMessage(done) |
