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

Unified Diff: client/cmd/isolate/upload_tracker.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 | « client/cmd/isolate/exp_archive.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/isolate/upload_tracker.go
diff --git a/client/cmd/isolate/upload_tracker.go b/client/cmd/isolate/upload_tracker.go
index 48cbd5075fe0edce76b1e3e10dfbea99a8278fd6..1274b67270f4fba93f4ee17ca5d1f25c6fef9786 100644
--- a/client/cmd/isolate/upload_tracker.go
+++ b/client/cmd/isolate/upload_tracker.go
@@ -17,7 +17,6 @@ package main
import (
"encoding/json"
"fmt"
- "io"
"io/ioutil"
"log"
"os"
@@ -38,6 +37,8 @@ type UploadTracker struct {
// NewUploadTracker constructs an UploadTracker. It tracks uploaded files in isol.Files.
func NewUploadTracker(checker *Checker, uploader *Uploader, isol *isolated.Isolated) *UploadTracker {
+ // TODO: share a Checker and Uploader with other UploadTrackers
+ // when batch uploading.
isol.Files = make(map[string]isolated.File)
return &UploadTracker{
checker: checker,
@@ -141,15 +142,20 @@ func (ut *UploadTracker) uploadFiles(files []*Item) error {
return nil
}
+// IsolatedSummary contains an isolate name and its digest.
+type IsolatedSummary struct {
+ // Name is the base name an isolated file with any extension stripped
+ Name string
+ Digest isolated.HexDigest
+}
+
// Finalize creates and uploads the isolate JSON at the isolatePath, and closes the checker and uploader.
-// It returns the isolate digest.
-// If dumpJSONPath is non-empty, the digest is also written to that path as
-// JSON (in the same format as batch_archive).
+// It returns the isolate name and digest.
// Finalize should only be called after UploadDeps.
-func (ut *UploadTracker) Finalize(isolatedPath string, dumpJSONWriter io.Writer) (isolated.HexDigest, error) {
+func (ut *UploadTracker) Finalize(isolatedPath string) (IsolatedSummary, error) {
isolFile, err := newIsolatedFile(ut.isol, isolatedPath)
if err != nil {
- return "", err
+ return IsolatedSummary{}, err
}
// Check and upload isolate JSON.
@@ -165,33 +171,23 @@ func (ut *UploadTracker) Finalize(isolatedPath string, dumpJSONWriter io.Writer)
// Make sure that all pending items have been checked.
if err := ut.checker.Close(); err != nil {
- return "", err
+ return IsolatedSummary{}, err
}
// Make sure that all the uploads have completed successfully.
if err := ut.uploader.Close(); err != nil {
- return "", err
+ return IsolatedSummary{}, err
}
- // Write the isolated file, and emit its digest to stdout.
+ // Write the isolated file...
if err := isolFile.writeJSONFile(); err != nil {
- return "", err
- }
-
- fmt.Printf("%s\t%s\n", isolFile.item().Digest, filepath.Base(isolatedPath))
-
- if err := dumpJSON(isolFile.name(), dumpJSONWriter, isolFile.item()); err != nil {
- return "", err
+ return IsolatedSummary{}, err
}
- return isolFile.item().Digest, nil
-}
-
-func dumpJSON(isolName string, dumpJSONWriter io.Writer, isolItem *Item) error {
- enc := json.NewEncoder(dumpJSONWriter)
- return enc.Encode(map[string]isolated.HexDigest{
- isolName: isolItem.Digest,
- })
+ return IsolatedSummary{
+ Name: isolFile.name(),
+ Digest: isolFile.item().Digest,
+ }, nil
}
// isolatedFile is an isolated file which is stored in memory.
« no previous file with comments | « client/cmd/isolate/exp_archive.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698