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

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

Issue 2983333002: isolate: Split UploadDeps into smaller chunks (Closed)
Patch Set: rebase 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 | no next file » | 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 6b164a9c9aabb161b7c68da8ed3204747c7c3937..d795b70b7ee0ac2220586f1e78f65817af8da481 100644
--- a/client/cmd/isolate/exp_archive.go
+++ b/client/cmd/isolate/exp_archive.go
@@ -187,18 +187,21 @@ func (ut *uploadTracker) Files() map[string]isolated.File {
return ut.files
}
-func (ut *uploadTracker) UploadDeps(parts partitionedDeps) error {
- // Handle the symlinks.
- for _, item := range parts.links.items {
+// populateSymlinks adds an isolated.File to files for each provided symlink
+func (ut *uploadTracker) populateSymlinks(symlinks []*Item) error {
+ for _, item := range symlinks {
l, err := os.Readlink(item.Path)
if err != nil {
return fmt.Errorf("unable to resolve symlink for %q: %v", item.Path, err)
}
ut.files[item.RelPath] = isolated.SymLink(l)
}
+ return nil
+}
- // Handle the small to-be-archived files.
- bundles := ShardItems(parts.filesToArchive.items, archiveMaxSize)
+// tarAndUploadFiles creates bundles of files, uploads them, and adds each bundle to files.
+func (ut *uploadTracker) tarAndUploadFiles(smallFiles []*Item) error {
+ bundles := ShardItems(smallFiles, archiveMaxSize)
log.Printf("\t%d TAR archives to be isolated", len(bundles))
for _, bundle := range bundles {
@@ -230,9 +233,13 @@ func (ut *uploadTracker) UploadDeps(parts partitionedDeps) error {
})
})
}
+ return nil
+}
+// uploadFiles uploads each file and adds it to files.
+func (ut *uploadTracker) uploadFiles(files []*Item) error {
// Handle the large individually-uploaded files.
- for _, item := range parts.indivFiles.items {
+ for _, item := range files {
d, err := hashFile(item.Path)
if err != nil {
return err
@@ -252,6 +259,21 @@ func (ut *uploadTracker) UploadDeps(parts partitionedDeps) error {
return nil
}
+func (ut *uploadTracker) UploadDeps(parts partitionedDeps) error {
+ if err := ut.populateSymlinks(parts.links.items); err != nil {
+ return err
+ }
+
+ if err := ut.tarAndUploadFiles(parts.filesToArchive.items); err != nil {
+ return err
+ }
+
+ if err := ut.uploadFiles(parts.indivFiles.items); err != nil {
+ return err
+ }
+ return nil
+}
+
// main contains the core logic for experimental archive.
func (c *expArchiveRun) main() error {
// TODO(djd): This func is long and has a lot of internal complexity (like,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698