| 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 isolatedclient | 5 package isolatedclient |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "encoding/base64" | 9 "encoding/base64" |
| 10 "errors" | 10 "errors" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 pr, pw := io.Pipe() | 342 pr, pw := io.Pipe() |
| 343 go func() { | 343 go func() { |
| 344 // The compressor itself is not thread safe. | 344 // The compressor itself is not thread safe. |
| 345 compressor, err := isolated.GetCompressor(pw) | 345 compressor, err := isolated.GetCompressor(pw) |
| 346 if err != nil { | 346 if err != nil { |
| 347 pw.CloseWithError(err) | 347 pw.CloseWithError(err) |
| 348 return | 348 return |
| 349 } | 349 } |
| 350 buf := make([]byte, 4096) | 350 buf := make([]byte, 4096) |
| 351 if _, err := io.CopyBuffer(compressor, src, buf); err != nil { | 351 if _, err := io.CopyBuffer(compressor, src, buf); err != nil { |
| 352 compressor.Close() |
| 352 pw.CloseWithError(err) | 353 pw.CloseWithError(err) |
| 353 return | 354 return |
| 354 } | 355 } |
| 355 pw.CloseWithError(compressor.Close()) | 356 pw.CloseWithError(compressor.Close()) |
| 356 }() | 357 }() |
| 357 | 358 |
| 358 return &compressed{pr, src} | 359 return &compressed{pr, src} |
| 359 } | 360 } |
| OLD | NEW |