| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 package main | 15 package main |
| 16 | 16 |
| 17 import ( | 17 import ( |
| 18 "errors" | 18 "errors" |
| 19 "fmt" | 19 "fmt" |
| 20 "io" |
| 21 "io/ioutil" |
| 20 "log" | 22 "log" |
| 21 "os" | 23 "os" |
| 22 "path/filepath" | 24 "path/filepath" |
| 23 "time" | 25 "time" |
| 24 | 26 |
| 25 humanize "github.com/dustin/go-humanize" | 27 humanize "github.com/dustin/go-humanize" |
| 26 "github.com/golang/protobuf/proto" | 28 "github.com/golang/protobuf/proto" |
| 27 "github.com/maruel/subcommands" | 29 "github.com/maruel/subcommands" |
| 28 "golang.org/x/net/context" | 30 "golang.org/x/net/context" |
| 29 | 31 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 filesSize := uint64(parts.filesToArchive.totalSize + parts.indivFiles.to
talSize) | 209 filesSize := uint64(parts.filesToArchive.totalSize + parts.indivFiles.to
talSize) |
| 208 log.Printf("Isolate expanded to %d files (total size %s) and %d symlinks
", numFiles, humanize.Bytes(filesSize), len(parts.links.items)) | 210 log.Printf("Isolate expanded to %d files (total size %s) and %d symlinks
", numFiles, humanize.Bytes(filesSize), len(parts.links.items)) |
| 209 log.Printf("\t%d files (%s) to be isolated individually", len(parts.indi
vFiles.items), humanize.Bytes(uint64(parts.indivFiles.totalSize))) | 211 log.Printf("\t%d files (%s) to be isolated individually", len(parts.indi
vFiles.items), humanize.Bytes(uint64(parts.indivFiles.totalSize))) |
| 210 log.Printf("\t%d files (%s) to be isolated in archives", len(parts.files
ToArchive.items), humanize.Bytes(uint64(parts.filesToArchive.totalSize))) | 212 log.Printf("\t%d files (%s) to be isolated in archives", len(parts.files
ToArchive.items), humanize.Bytes(uint64(parts.filesToArchive.totalSize))) |
| 211 | 213 |
| 212 tracker := NewUploadTracker(checker, uploader, isol) | 214 tracker := NewUploadTracker(checker, uploader, isol) |
| 213 if err := tracker.UploadDeps(parts); err != nil { | 215 if err := tracker.UploadDeps(parts); err != nil { |
| 214 return err | 216 return err |
| 215 } | 217 } |
| 216 | 218 |
| 217 » isolDigest, err := tracker.Finalize(archiveOpts.Isolated, c.dumpJSON) | 219 » var dumpJSONWriter io.Writer = ioutil.Discard |
| 220 |
| 221 » if c.dumpJSON != "" { |
| 222 » » f, err := os.OpenFile(c.dumpJSON, os.O_RDWR|os.O_CREATE|os.O_TRU
NC, 0644) |
| 223 » » if err != nil { |
| 224 » » » return err |
| 225 » » } |
| 226 » » defer f.Close() |
| 227 » » dumpJSONWriter = f |
| 228 » } |
| 229 |
| 230 » isolDigest, err := tracker.Finalize(archiveOpts.Isolated, dumpJSONWriter
) |
| 218 if err != nil { | 231 if err != nil { |
| 219 return err | 232 return err |
| 220 } | 233 } |
| 221 | 234 |
| 222 end := time.Now() | 235 end := time.Now() |
| 223 | 236 |
| 224 archiveDetails := &logpb.IsolateClientEvent_ArchiveDetails{ | 237 archiveDetails := &logpb.IsolateClientEvent_ArchiveDetails{ |
| 225 HitCount: proto.Int64(int64(checker.Hit.Count)), | 238 HitCount: proto.Int64(int64(checker.Hit.Count)), |
| 226 MissCount: proto.Int64(int64(checker.Miss.Count)), | 239 MissCount: proto.Int64(int64(checker.Miss.Count)), |
| 227 HitBytes: &checker.Hit.Bytes, | 240 HitBytes: &checker.Hit.Bytes, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 281 } |
| 269 | 282 |
| 270 func hashFile(path string) (isolated.HexDigest, error) { | 283 func hashFile(path string) (isolated.HexDigest, error) { |
| 271 f, err := os.Open(path) | 284 f, err := os.Open(path) |
| 272 if err != nil { | 285 if err != nil { |
| 273 return "", err | 286 return "", err |
| 274 } | 287 } |
| 275 defer f.Close() | 288 defer f.Close() |
| 276 return isolated.Hash(f) | 289 return isolated.Hash(f) |
| 277 } | 290 } |
| OLD | NEW |