From 07a42aaa40eb603218ea75ead18a566e02cd5dbe Mon Sep 17 00:00:00 2001 From: Aaron Racine Date: Thu, 2 Jan 2014 17:55:17 -0800 Subject: [PATCH] camput: Skip base directories where IsIgnoredFile() returns true. camput currently panics if a base directory is ignored. Fixes issue 314. Change-Id: I9466b4576b1134994e5e53e1067e0435ddba0fdf --- cmd/camput/files.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/camput/files.go b/cmd/camput/files.go index 27879df14..f5f28f800 100644 --- a/cmd/camput/files.go +++ b/cmd/camput/files.go @@ -230,6 +230,12 @@ func (c *fileCmd) RunCommand(args []string) error { if err != nil { return err } + // Skip ignored files or base directories. Failing to skip the + // latter results in a panic. + if up.Client.IsIgnoredFile(filename) { + log.Printf("Client configured to ignore %s; skipping.", filename) + continue + } if fi.IsDir() { if up.fileOpts.wantVivify() { vlog.Printf("Directories not supported in vivify mode; skipping %v\n", filename) @@ -239,9 +245,6 @@ func (c *fileCmd) RunCommand(args []string) error { t.Start() lastPut, err = t.Wait() } else { - if up.Client.IsIgnoredFile(filename) { - continue - } lastPut, err = up.UploadFile(filename) if err == nil && c.deleteAfterUpload { if err := os.Remove(filename); err != nil {