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

Side by Side Diff: client/cmd/isolate/exp_archive.go

Issue 2988133002: isolate: manage lifetime of checker and uploader in main. (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | client/cmd/isolate/upload_tracker.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 // Set up a checker and uploader. We limit the uploader to one concurren t 92 // Set up a checker and uploader. We limit the uploader to one concurren t
93 // upload, since the uploads are all coming from disk (with the exceptio n of 93 // upload, since the uploads are all coming from disk (with the exceptio n of
94 // the isolated JSON itself) and we only want a single goroutine reading from 94 // the isolated JSON itself) and we only want a single goroutine reading from
95 // disk at once. 95 // disk at once.
96 checker := NewChecker(ctx, client) 96 checker := NewChecker(ctx, client)
97 uploader := NewUploader(ctx, client, 1) 97 uploader := NewUploader(ctx, client, 1)
98 archiver := NewTarringArchiver(checker, uploader) 98 archiver := NewTarringArchiver(checker, uploader)
99 99
100 isolSummary, err := archiver.Archive(archiveOpts) 100 isolSummary, err := archiver.Archive(archiveOpts)
101
102 // Make sure that all pending items have been checked.
103 if err := checker.Close(); err != nil {
104 return err
105 }
106
107 // Make sure that all the uploads have completed successfully.
108 if err := uploader.Close(); err != nil {
109 return err
110 }
111
101 printSummary(isolSummary) 112 printSummary(isolSummary)
102 if c.dumpJSON != "" { 113 if c.dumpJSON != "" {
103 f, err := os.OpenFile(c.dumpJSON, os.O_RDWR|os.O_CREATE|os.O_TRU NC, 0644) 114 f, err := os.OpenFile(c.dumpJSON, os.O_RDWR|os.O_CREATE|os.O_TRU NC, 0644)
104 if err != nil { 115 if err != nil {
105 return err 116 return err
106 } 117 }
107 writeSummaryJSON(f, isolSummary) 118 writeSummaryJSON(f, isolSummary)
108 f.Close() 119 f.Close()
109 } 120 }
110 121
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 181 }
171 182
172 func hashFile(path string) (isolated.HexDigest, error) { 183 func hashFile(path string) (isolated.HexDigest, error) {
173 f, err := os.Open(path) 184 f, err := os.Open(path)
174 if err != nil { 185 if err != nil {
175 return "", err 186 return "", err
176 } 187 }
177 defer f.Close() 188 defer f.Close()
178 return isolated.Hash(f) 189 return isolated.Hash(f)
179 } 190 }
OLDNEW
« 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