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

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

Issue 2981223003: Reuse blacklisting code in exp_archive. (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 | client/cmd/isolate/exp_archive_test.go » ('j') | 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 a65bccaf5f1d7afade8d43c0d3a17ffc4f2cbbb6..c561f247036b5e4199b7d4a3ee821daf66e4bc06 100644
--- a/client/cmd/isolate/exp_archive.go
+++ b/client/cmd/isolate/exp_archive.go
@@ -30,6 +30,7 @@ import (
"github.com/maruel/subcommands"
"golang.org/x/net/context"
+ "github.com/luci/luci-go/client/internal/common"
"github.com/luci/luci-go/client/isolate"
"github.com/luci/luci-go/common/auth"
logpb "github.com/luci/luci-go/common/eventlog/proto"
@@ -100,8 +101,8 @@ func (ig *itemGroup) AddItem(item *Item) {
// partitioningWalker contains the state necessary to partition isolate deps by handling multiple os.WalkFunc invocations.
type partitioningWalker struct {
- // rootDir must be initialized before walkFn is called.
- rootDir string
+ // fsView must be initialized before walkFn is called.
+ fsView common.FilesystemView
parts partitionedDeps
}
@@ -119,15 +120,20 @@ func (pw *partitioningWalker) walkFn(path string, info os.FileInfo, err error) e
if err != nil {
return err
}
- if info.IsDir() {
- return nil
- }
- relPath, err := filepath.Rel(pw.rootDir, path)
+ relPath, err := pw.fsView.RelativePath(path)
if err != nil {
return err
}
+ if relPath == "" { // empty string indicates skip.
+ return returnSkip(info)
+ }
+
+ if info.IsDir() {
+ return nil
+ }
+
item := &Item{
Path: path,
RelPath: relPath,
@@ -146,9 +152,24 @@ func (pw *partitioningWalker) walkFn(path string, info os.FileInfo, err error) e
return nil
}
+// returnSkip returns the return value expected from a filepath.WalkFunc in the case where no more processing of file should occur.
mithro 2017/07/21 04:58:51 nit: This sentence is a bit clunky.
mcgreevy 2017/07/21 05:40:38 I've reworded; it's quite hard to word simply, tho
+func returnSkip(file os.FileInfo) error {
+ if file.IsDir() {
+ // Must not return io.SkipDir for file, filepath.walk() handles this badly.
mithro 2017/07/21 04:58:51 Could you add a reference to info about this? Mayb
mcgreevy 2017/07/21 05:40:38 Done.
+ return filepath.SkipDir
+ }
+ return nil
+}
+
// partitionDeps walks each of the deps, partioning the results into symlinks and files categorized by size.
func partitionDeps(deps []string, rootDir string) (partitionedDeps, error) {
- walker := partitioningWalker{rootDir: rootDir}
+ // TODO(mcgreevy): initialize FilesystemView with blacklist.
+ fsView, err := common.NewFilesystemView(rootDir, nil)
+ if err != nil {
+ return partitionedDeps{}, err
+ }
+
+ walker := partitioningWalker{fsView: fsView}
for _, dep := range deps {
// Try to walk dep. If dep is a file (or symlink), the inner function is called exactly once.
if err := filepath.Walk(filepath.Clean(dep), walker.walkFn); err != nil {
« no previous file with comments | « no previous file | client/cmd/isolate/exp_archive_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698