| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 pw.parts.links.AddItem(item) | 146 pw.parts.links.AddItem(item) |
| 147 case item.Size < archiveThreshold: | 147 case item.Size < archiveThreshold: |
| 148 pw.parts.filesToArchive.AddItem(item) | 148 pw.parts.filesToArchive.AddItem(item) |
| 149 default: | 149 default: |
| 150 pw.parts.indivFiles.AddItem(item) | 150 pw.parts.indivFiles.AddItem(item) |
| 151 } | 151 } |
| 152 return nil | 152 return nil |
| 153 } | 153 } |
| 154 | 154 |
| 155 // partitionDeps walks each of the deps, partioning the results into symlinks an
d files categorized by size. | 155 // partitionDeps walks each of the deps, partioning the results into symlinks an
d files categorized by size. |
| 156 func partitionDeps(deps []string, rootDir string) (partitionedDeps, error) { | 156 func partitionDeps(deps []string, rootDir string, blacklist []string) (partition
edDeps, error) { |
| 157 » // TODO(mcgreevy): initialize FilesystemView with blacklist. | 157 » fsView, err := common.NewFilesystemView(rootDir, blacklist) |
| 158 » fsView, err := common.NewFilesystemView(rootDir, nil) | |
| 159 if err != nil { | 158 if err != nil { |
| 160 return partitionedDeps{}, err | 159 return partitionedDeps{}, err |
| 161 } | 160 } |
| 162 | 161 |
| 163 walker := partitioningWalker{fsView: fsView} | 162 walker := partitioningWalker{fsView: fsView} |
| 164 for _, dep := range deps { | 163 for _, dep := range deps { |
| 165 // Try to walk dep. If dep is a file (or symlink), the inner fun
ction is called exactly once. | 164 // Try to walk dep. If dep is a file (or symlink), the inner fun
ction is called exactly once. |
| 166 if err := filepath.Walk(filepath.Clean(dep), walker.walkFn); err
!= nil { | 165 if err := filepath.Walk(filepath.Clean(dep), walker.walkFn); err
!= nil { |
| 167 return partitionedDeps{}, err | 166 return partitionedDeps{}, err |
| 168 } | 167 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 195 } | 194 } |
| 196 client := isolatedclient.New(nil, authCl, c.isolatedFlags.ServerURL, c.i
solatedFlags.Namespace, nil, nil) | 195 client := isolatedclient.New(nil, authCl, c.isolatedFlags.ServerURL, c.i
solatedFlags.Namespace, nil, nil) |
| 197 | 196 |
| 198 // Set up a checker and uploader. We limit the uploader to one concurren
t | 197 // Set up a checker and uploader. We limit the uploader to one concurren
t |
| 199 // upload, since the uploads are all coming from disk (with the exceptio
n of | 198 // upload, since the uploads are all coming from disk (with the exceptio
n of |
| 200 // the isolated JSON itself) and we only want a single goroutine reading
from | 199 // the isolated JSON itself) and we only want a single goroutine reading
from |
| 201 // disk at once. | 200 // disk at once. |
| 202 checker := NewChecker(ctx, client) | 201 checker := NewChecker(ctx, client) |
| 203 uploader := NewUploader(ctx, client, 1) | 202 uploader := NewUploader(ctx, client, 1) |
| 204 | 203 |
| 205 » parts, err := partitionDeps(deps, rootDir) | 204 » parts, err := partitionDeps(deps, rootDir, c.isolateFlags.ArchiveOptions
.Blacklist) |
| 206 if err != nil { | 205 if err != nil { |
| 207 return fmt.Errorf("partitioning deps: %v", err) | 206 return fmt.Errorf("partitioning deps: %v", err) |
| 208 } | 207 } |
| 209 | 208 |
| 210 // Construct a map of the files that constitute the isolate. | 209 // Construct a map of the files that constitute the isolate. |
| 211 files := make(map[string]isolated.File) | 210 files := make(map[string]isolated.File) |
| 212 | 211 |
| 213 numFiles := len(parts.filesToArchive.items) + len(parts.indivFiles.items
) | 212 numFiles := len(parts.filesToArchive.items) + len(parts.indivFiles.items
) |
| 214 filesSize := uint64(parts.filesToArchive.totalSize + parts.indivFiles.to
talSize) | 213 filesSize := uint64(parts.filesToArchive.totalSize + parts.indivFiles.to
talSize) |
| 215 log.Printf("Isolate expanded to %d files (total size %s) and %d symlinks
", numFiles, humanize.Bytes(filesSize), len(parts.links.items)) | 214 log.Printf("Isolate expanded to %d files (total size %s) and %d symlinks
", numFiles, humanize.Bytes(filesSize), len(parts.links.items)) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 371 } |
| 373 return nil | 372 return nil |
| 374 } | 373 } |
| 375 | 374 |
| 376 func (c *expArchiveRun) Run(a subcommands.Application, args []string, _ subcomma
nds.Env) int { | 375 func (c *expArchiveRun) Run(a subcommands.Application, args []string, _ subcomma
nds.Env) int { |
| 377 fmt.Fprintln(a.GetErr(), "WARNING: this command is experimental") | 376 fmt.Fprintln(a.GetErr(), "WARNING: this command is experimental") |
| 378 if err := c.parseFlags(args); err != nil { | 377 if err := c.parseFlags(args); err != nil { |
| 379 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err) | 378 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err) |
| 380 return 1 | 379 return 1 |
| 381 } | 380 } |
| 382 if len(c.isolateFlags.ArchiveOptions.Blacklist) != 0 { | |
| 383 fmt.Fprintf(a.GetErr(), "%s: blacklist is not supported\n", a.Ge
tName()) | |
| 384 return 1 | |
| 385 } | |
| 386 if err := c.main(); err != nil { | 381 if err := c.main(); err != nil { |
| 387 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err) | 382 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err) |
| 388 return 1 | 383 return 1 |
| 389 } | 384 } |
| 390 return 0 | 385 return 0 |
| 391 } | 386 } |
| 392 | 387 |
| 393 func hashFile(path string) (isolated.HexDigest, error) { | 388 func hashFile(path string) (isolated.HexDigest, error) { |
| 394 f, err := os.Open(path) | 389 f, err := os.Open(path) |
| 395 if err != nil { | 390 if err != nil { |
| 396 return "", err | 391 return "", err |
| 397 } | 392 } |
| 398 defer f.Close() | 393 defer f.Close() |
| 399 return isolated.Hash(f) | 394 return isolated.Hash(f) |
| 400 } | 395 } |
| OLD | NEW |