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, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if err != nil { | 205 if err != nil { |
206 return fmt.Errorf("partitioning deps: %v", err) | 206 return fmt.Errorf("partitioning deps: %v", err) |
207 } | 207 } |
208 | 208 |
209 numFiles := len(parts.filesToArchive.items) + len(parts.indivFiles.items
) | 209 numFiles := len(parts.filesToArchive.items) + len(parts.indivFiles.items
) |
210 filesSize := uint64(parts.filesToArchive.totalSize + parts.indivFiles.to
talSize) | 210 filesSize := uint64(parts.filesToArchive.totalSize + parts.indivFiles.to
talSize) |
211 log.Printf("Isolate expanded to %d files (total size %s) and %d symlinks
", numFiles, humanize.Bytes(filesSize), len(parts.links.items)) | 211 log.Printf("Isolate expanded to %d files (total size %s) and %d symlinks
", numFiles, humanize.Bytes(filesSize), len(parts.links.items)) |
212 log.Printf("\t%d files (%s) to be isolated individually", len(parts.indi
vFiles.items), humanize.Bytes(uint64(parts.indivFiles.totalSize))) | 212 log.Printf("\t%d files (%s) to be isolated individually", len(parts.indi
vFiles.items), humanize.Bytes(uint64(parts.indivFiles.totalSize))) |
213 log.Printf("\t%d files (%s) to be isolated in archives", len(parts.files
ToArchive.items), humanize.Bytes(uint64(parts.filesToArchive.totalSize))) | 213 log.Printf("\t%d files (%s) to be isolated in archives", len(parts.files
ToArchive.items), humanize.Bytes(uint64(parts.filesToArchive.totalSize))) |
214 | 214 |
215 » tracker := NewUploadTracker(checker, uploader) | 215 » tracker := NewUploadTracker(checker, uploader, isol) |
216 if err := tracker.UploadDeps(parts); err != nil { | 216 if err := tracker.UploadDeps(parts); err != nil { |
217 return err | 217 return err |
218 } | 218 } |
219 | 219 |
220 » isol.Files = tracker.Files() | 220 » isolItem, isolJSON, err := tracker.Finalize(archiveOpts.Isolated) |
221 | |
222 » // Marshal the isolated file into JSON, and create an Item to describe i
t. | |
223 » var isolJSON []byte | |
224 » isolJSON, err = json.Marshal(isol) | |
225 if err != nil { | 221 if err != nil { |
226 return err | 222 return err |
227 } | 223 } |
228 isolItem := &Item{ | |
229 Path: archiveOpts.Isolated, | |
230 RelPath: filepath.Base(archiveOpts.Isolated), | |
231 Digest: isolated.HashBytes(isolJSON), | |
232 Size: int64(len(isolJSON)), | |
233 } | |
234 | |
235 // Check and upload isolate JSON. | |
236 checker.AddItem(isolItem, true, func(item *Item, ps *isolatedclient.Push
State) { | |
237 if ps == nil { | |
238 return | |
239 } | |
240 log.Printf("QUEUED %q for upload", item.RelPath) | |
241 uploader.UploadBytes(item.RelPath, isolJSON, ps, func() { | |
242 log.Printf("UPLOADED %q", item.RelPath) | |
243 }) | |
244 }) | |
245 | 224 |
246 // Make sure that all pending items have been checked. | 225 // Make sure that all pending items have been checked. |
247 if err := checker.Close(); err != nil { | 226 if err := checker.Close(); err != nil { |
248 return err | 227 return err |
249 } | 228 } |
250 | 229 |
251 // Make sure that all the uploads have completed successfully. | 230 // Make sure that all the uploads have completed successfully. |
252 if err := uploader.Close(); err != nil { | 231 if err := uploader.Close(); err != nil { |
253 return err | 232 return err |
254 } | 233 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 306 } |
328 | 307 |
329 func hashFile(path string) (isolated.HexDigest, error) { | 308 func hashFile(path string) (isolated.HexDigest, error) { |
330 f, err := os.Open(path) | 309 f, err := os.Open(path) |
331 if err != nil { | 310 if err != nil { |
332 return "", err | 311 return "", err |
333 } | 312 } |
334 defer f.Close() | 313 defer f.Close() |
335 return isolated.Hash(f) | 314 return isolated.Hash(f) |
336 } | 315 } |
OLD | NEW |