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

Side by Side Diff: client/cmd/isolate/upload_tracker.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 | « client/cmd/isolate/exp_archive.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The LUCI Authors. 1 // Copyright 2017 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ut.checker.AddItem(isolFile.item(), true, func(item *Item, ps *isolatedc lient.PushState) { 190 ut.checker.AddItem(isolFile.item(), true, func(item *Item, ps *isolatedc lient.PushState) {
191 if ps == nil { 191 if ps == nil {
192 return 192 return
193 } 193 }
194 log.Printf("QUEUED %q for upload", item.RelPath) 194 log.Printf("QUEUED %q for upload", item.RelPath)
195 ut.uploader.UploadBytes(item.RelPath, isolFile.contents(), ps, f unc() { 195 ut.uploader.UploadBytes(item.RelPath, isolFile.contents(), ps, f unc() {
196 log.Printf("UPLOADED %q", item.RelPath) 196 log.Printf("UPLOADED %q", item.RelPath)
197 }) 197 })
198 }) 198 })
199 199
200 // Make sure that all pending items have been checked.
201 if err := ut.checker.Close(); err != nil {
202 return IsolatedSummary{}, err
203 }
204
205 // Make sure that all the uploads have completed successfully.
206 if err := ut.uploader.Close(); err != nil {
207 return IsolatedSummary{}, err
208 }
209
210 // Write the isolated file... 200 // Write the isolated file...
211 if err := isolFile.writeJSONFile(ut.lOS); err != nil { 201 if err := isolFile.writeJSONFile(ut.lOS); err != nil {
212 return IsolatedSummary{}, err 202 return IsolatedSummary{}, err
213 } 203 }
214 204
215 return IsolatedSummary{ 205 return IsolatedSummary{
216 Name: isolFile.name(), 206 Name: isolFile.name(),
217 Digest: isolFile.item().Digest, 207 Digest: isolFile.item().Digest,
218 }, nil 208 }, nil
219 } 209 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 253 }
264 254
265 // name returns the base name of the isolated file, extension stripped. 255 // name returns the base name of the isolated file, extension stripped.
266 func (ij *isolatedFile) name() string { 256 func (ij *isolatedFile) name() string {
267 name := filepath.Base(ij.path) 257 name := filepath.Base(ij.path)
268 if i := strings.LastIndex(name, "."); i != -1 { 258 if i := strings.LastIndex(name, "."); i != -1 {
269 name = name[:i] 259 name = name[:i]
270 } 260 }
271 return name 261 return name
272 } 262 }
OLDNEW
« 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