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

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

Issue 2981223003: Reuse blacklisting code in exp_archive. (Closed)
Patch Set: address review comments 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 | « client/archiver/directory.go ('k') | 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..ea9d1276f7a875fc56aaf66706ec800f1b28e95e 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 common.WalkFuncSkipFile(info)
+ }
+
+ if info.IsDir() {
+ return nil
+ }
+
item := &Item{
Path: path,
RelPath: relPath,
@@ -148,7 +154,13 @@ func (pw *partitioningWalker) walkFn(path string, info os.FileInfo, err error) e
// 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 | « client/archiver/directory.go ('k') | client/cmd/isolate/exp_archive_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698