Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6011)

Unified Diff: client/cmd/isolate/exp_archive.go

Issue 2985203002: isolate: Move json dumping back into exparchive main (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/cmd/isolate/upload_tracker.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/isolate/exp_archive.go
diff --git a/client/cmd/isolate/exp_archive.go b/client/cmd/isolate/exp_archive.go
index a6650655e3231d62fa7f35c7800aebe37515239b..c846b71aa893c4baedef4b8d822f6573865384ab 100644
--- a/client/cmd/isolate/exp_archive.go
+++ b/client/cmd/isolate/exp_archive.go
@@ -15,10 +15,10 @@
package main
import (
+ "encoding/json"
"errors"
"fmt"
"io"
- "io/ioutil"
"log"
"os"
"path/filepath"
@@ -215,21 +215,19 @@ func (c *expArchiveRun) main() error {
if err := tracker.UploadDeps(parts); err != nil {
return err
}
+ isolSummary, err := tracker.Finalize(archiveOpts.Isolated)
+ if err != nil {
+ return err
+ }
- var dumpJSONWriter io.Writer = ioutil.Discard
-
+ printSummary(isolSummary)
if c.dumpJSON != "" {
f, err := os.OpenFile(c.dumpJSON, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return err
}
- defer f.Close()
- dumpJSONWriter = f
- }
-
- isolDigest, err := tracker.Finalize(archiveOpts.Isolated, dumpJSONWriter)
- if err != nil {
- return err
+ writeSummaryJSON(f, isolSummary)
+ f.Close()
}
end := time.Now()
@@ -239,7 +237,7 @@ func (c *expArchiveRun) main() error {
MissCount: proto.Int64(int64(checker.Miss.Count)),
HitBytes: &checker.Hit.Bytes,
MissBytes: &checker.Miss.Bytes,
- IsolateHash: []string{string(isolDigest)},
+ IsolateHash: []string{string(isolSummary.Digest)},
}
eventlogger := NewLogger(ctx, c.loggingFlags.EventlogEndpoint)
op := logpb.IsolateClientEvent_ARCHIVE.Enum()
@@ -250,6 +248,19 @@ func (c *expArchiveRun) main() error {
return nil
}
+func writeSummaryJSON(w io.Writer, summaries ...IsolatedSummary) error {
+ m := make(map[string]isolated.HexDigest)
+ for _, summary := range summaries {
+ m[summary.Name] = summary.Digest
+ }
+
+ return json.NewEncoder(w).Encode(m)
+}
+
+func printSummary(summary IsolatedSummary) {
+ fmt.Printf("%s\t%s\n", summary.Digest, summary.Name)
+}
+
func (c *expArchiveRun) parseFlags(args []string) error {
if len(args) != 0 {
return errors.New("position arguments not expected")
« no previous file with comments | « no previous file | client/cmd/isolate/upload_tracker.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698