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

Side by Side Diff: client/cmd/isolate/batch_archive.go

Issue 2941963002: Remove batcharchive dependency on common.IsDirectory (Closed)
Patch Set: Remove unused import Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | client/internal/common/utils.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "errors" 9 "errors"
10 "fmt" 10 "fmt"
11 "io" 11 "io"
12 "os" 12 "os"
13 "path/filepath" 13 "path/filepath"
14 "strings" 14 "strings"
15 "sync" 15 "sync"
16 "time" 16 "time"
17 17
18 "github.com/maruel/subcommands" 18 "github.com/maruel/subcommands"
19 19
20 "github.com/luci/luci-go/client/archiver" 20 "github.com/luci/luci-go/client/archiver"
21 "github.com/luci/luci-go/client/internal/common"
22 "github.com/luci/luci-go/client/isolate" 21 "github.com/luci/luci-go/client/isolate"
23 "github.com/luci/luci-go/common/auth" 22 "github.com/luci/luci-go/common/auth"
24 "github.com/luci/luci-go/common/data/text/units" 23 "github.com/luci/luci-go/common/data/text/units"
25 "github.com/luci/luci-go/common/isolated" 24 "github.com/luci/luci-go/common/isolated"
26 "github.com/luci/luci-go/common/isolatedclient" 25 "github.com/luci/luci-go/common/isolatedclient"
27 ) 26 )
28 27
29 func cmdBatchArchive(defaultAuthOpts auth.Options) *subcommands.Command { 28 func cmdBatchArchive(defaultAuthOpts auth.Options) *subcommands.Command {
30 return &subcommands.Command{ 29 return &subcommands.Command{
31 UsageLine: "batcharchive <options> file1 file2 ...", 30 UsageLine: "batcharchive <options> file1 file2 ...",
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 Dir string 208 Dir string
210 Version int 209 Version int
211 }{} 210 }{}
212 if err := json.NewDecoder(r).Decode(data); err != nil { 211 if err := json.NewDecoder(r).Decode(data); err != nil {
213 return nil, fmt.Errorf("failed to decode: %s", err) 212 return nil, fmt.Errorf("failed to decode: %s", err)
214 } 213 }
215 214
216 if data.Version != isolate.IsolatedGenJSONVersion { 215 if data.Version != isolate.IsolatedGenJSONVersion {
217 return nil, fmt.Errorf("invalid version %d", data.Version) 216 return nil, fmt.Errorf("invalid version %d", data.Version)
218 } 217 }
219 » if !common.IsDirectory(data.Dir) { 218
219 » if fileInfo, err := os.Stat(data.Dir); err != nil || !fileInfo.IsDir() {
220 return nil, fmt.Errorf("invalid dir %s", data.Dir) 220 return nil, fmt.Errorf("invalid dir %s", data.Dir)
221 } 221 }
222
222 opts, err := parseArchiveCMD(data.Args, data.Dir) 223 opts, err := parseArchiveCMD(data.Args, data.Dir)
223 if err != nil { 224 if err != nil {
224 return nil, fmt.Errorf("invalid archive command: %s", err) 225 return nil, fmt.Errorf("invalid archive command: %s", err)
225 } 226 }
226 return opts, nil 227 return opts, nil
227 } 228 }
228 229
229 // strippedIsolatedName returns the base name of an isolated path, with the exte nsion (if any) removed. 230 // strippedIsolatedName returns the base name of an isolated path, with the exte nsion (if any) removed.
230 func strippedIsolatedName(isolated string) string { 231 func strippedIsolatedName(isolated string) string {
231 name := filepath.Base(isolated) 232 name := filepath.Base(isolated)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err) 273 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
273 return 1 274 return 1
274 } 275 }
275 defer cl.Close() 276 defer cl.Close()
276 if err := c.main(a, args); err != nil { 277 if err := c.main(a, args); err != nil {
277 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err) 278 fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
278 return 1 279 return 1
279 } 280 }
280 return 0 281 return 0
281 } 282 }
OLDNEW
« no previous file with comments | « no previous file | client/internal/common/utils.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698