| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "io" | 9 "io" |
| 10 "os" | 10 "os" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 path = fmt.Sprintf("%s.%s", base, ext) | 67 path = fmt.Sprintf("%s.%s", base, ext) |
| 68 } else { | 68 } else { |
| 69 path = fmt.Sprintf("%s.%d.%s", base, idx, ext) | 69 path = fmt.Sprintf("%s.%d.%s", base, idx, ext) |
| 70 } | 70 } |
| 71 return path | 71 return path |
| 72 } | 72 } |
| 73 | 73 |
| 74 func (c *filesystemClient) NewStream(f streamproto.Flags) (streamclient.Stream,
error) { | 74 func (c *filesystemClient) NewStream(f streamproto.Flags) (streamclient.Stream,
error) { |
| 75 s := filesystemClientStream{ | 75 s := filesystemClientStream{ |
| 76 filesystemClient: c, | 76 filesystemClient: c, |
| 77 props: f.Properties(), |
| 77 baseName: sanitize(string(f.Name)), | 78 baseName: sanitize(string(f.Name)), |
| 78 contentType: f.ContentType, | 79 contentType: f.ContentType, |
| 79 streamType: logpb.StreamType(f.Type), | 80 streamType: logpb.StreamType(f.Type), |
| 80 } | 81 } |
| 81 | 82 |
| 82 // Open our output file for writing. | 83 // Open our output file for writing. |
| 83 return &s, nil | 84 return &s, nil |
| 84 } | 85 } |
| 85 | 86 |
| 86 type filesystemClientStream struct { | 87 type filesystemClientStream struct { |
| 87 *filesystemClient | 88 *filesystemClient |
| 88 | 89 |
| 90 props *streamproto.Properties |
| 89 baseName string | 91 baseName string |
| 90 contentType string | 92 contentType string |
| 91 streamType logpb.StreamType | 93 streamType logpb.StreamType |
| 92 | 94 |
| 93 writer io.WriteCloser | 95 writer io.WriteCloser |
| 94 dgIdx int | 96 dgIdx int |
| 95 } | 97 } |
| 96 | 98 |
| 97 func (s *filesystemClientStream) create(filename string) (io.WriteCloser, error)
{ | 99 func (s *filesystemClientStream) create(filename string) (io.WriteCloser, error)
{ |
| 98 path := filepath.Join(s.dir, filename) | 100 path := filepath.Join(s.dir, filename) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return nil | 167 return nil |
| 166 } | 168 } |
| 167 | 169 |
| 168 func (s *filesystemClientStream) Close() error { | 170 func (s *filesystemClientStream) Close() error { |
| 169 if w := s.writer; w != nil { | 171 if w := s.writer; w != nil { |
| 170 s.writer = nil | 172 s.writer = nil |
| 171 return w.Close() | 173 return w.Close() |
| 172 } | 174 } |
| 173 return nil | 175 return nil |
| 174 } | 176 } |
| 177 |
| 178 func (s *filesystemClientStream) Properties() *streamproto.Properties { return s
.props.Clone() } |
| OLD | NEW |