Skip to content

Commit

Permalink
SNOW-1738453 Add flag to ensure folder exists before copy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ikryvanos committed Oct 15, 2024
1 parent 65c6ba1 commit 3b382c9
Show file tree
Hide file tree
Showing 6 changed files with 408 additions and 296 deletions.
21 changes: 12 additions & 9 deletions services/localfile/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,14 +978,15 @@ func (p *lsCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{
}

type cpCmd struct {
bucket string
overwrite bool
uid int
username string
gid int
group string
mode int
immutable bool
bucket string
overwrite bool
ensureOutputDir bool
uid int
username string
gid int
group string
mode int
immutable bool
}

func (*cpCmd) Name() string { return "cp" }
Expand All @@ -1003,6 +1004,7 @@ sure to use a fully formed directory. i.e. copying /etc/hosts would be --bucket=
func (p *cpCmd) SetFlags(f *flag.FlagSet) {
f.StringVar(&p.bucket, "bucket", "", "If set to a valid prefix will copy from this bucket with the key being the source provided")
f.BoolVar(&p.overwrite, "overwrite", false, "If true will overwrite the remote file. Otherwise the file pre-existing is an error.")
f.BoolVar(&p.ensureOutputDir, "ensure-output-dir", false, "If true will ensure output dir exists before copy. Otherwise the if folder not exists copy would fail.")
f.IntVar(&p.uid, "uid", -1, "The uid the remote file will be set via chown.")
f.IntVar(&p.gid, "gid", -1, "The gid the remote file will be set via chown.")
f.IntVar(&p.mode, "mode", -1, "The mode the remote file will be set via chmod.")
Expand Down Expand Up @@ -1074,7 +1076,8 @@ func (p *cpCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{
},
},
},
Overwrite: p.overwrite,
Overwrite: p.overwrite,
EnsureOutputDirectory: p.ensureOutputDir,
}
if p.uid >= 0 {
descr.Attrs.Attributes = append(descr.Attrs.Attributes, &pb.FileAttribute{
Expand Down
Loading

0 comments on commit 3b382c9

Please sign in to comment.