From 55a86110d7e82dc218bd95ccfd27f5e90af0b6d9 Mon Sep 17 00:00:00 2001 From: Pawel Smolenski Date: Fri, 15 Nov 2024 14:43:19 +0100 Subject: [PATCH] Moved `ParseFileMode` function from `utils` to `client` since it is used only in `client` file. --- services/localfile/client/client.go | 15 ++++++++++++--- services/localfile/client/utils.go | 9 --------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/localfile/client/client.go b/services/localfile/client/client.go index fbc58732..c62025eb 100644 --- a/services/localfile/client/client.go +++ b/services/localfile/client/client.go @@ -26,6 +26,7 @@ import ( "io/fs" "os" "sort" + "strconv" "strings" "time" @@ -766,7 +767,7 @@ func (c *chmodCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa return subcommands.ExitFailure } - mode, err := ParseFileMode(c.mode) + mode, err := parseFileMode(c.mode) if err != nil { fmt.Fprintln(os.Stderr, "Invalid --mode '%s'. An octal number expected (e.g. 644, 755, 0777).\n", c.mode) @@ -1066,7 +1067,7 @@ func (p *cpCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{ } } - mode, err := ParseFileMode(p.mode) + mode, err := parseFileMode(p.mode) if err != nil { fmt.Fprintf(os.Stderr, "Invalid --mode '%s'. An octal number expected (e.g. 644, 755, 0777).\n", p.mode) @@ -1412,7 +1413,7 @@ func (p *mkdirCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa c := pb.NewLocalFileClientProxy(state.Conn) directoryName := f.Args()[0] - mode, err := ParseFileMode(p.mode) + mode, err := parseFileMode(p.mode) if err != nil { fmt.Fprintf(os.Stderr, "Invalid --mode '%s'. An octal number expected (e.g. 644, 755, 0777).\n", p.mode) @@ -1482,3 +1483,11 @@ func (p *mkdirCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa return retCode } + +const fileModeSizeInBits = 12 + +func parseFileMode(modeStr string) (uint16, error) { + mode, err := strconv.ParseUint(modeStr, 8, fileModeSizeInBits) + + return uint16(mode), err +} diff --git a/services/localfile/client/utils.go b/services/localfile/client/utils.go index f5d95b22..b3ac2936 100644 --- a/services/localfile/client/utils.go +++ b/services/localfile/client/utils.go @@ -23,7 +23,6 @@ import ( "fmt" "io" "path/filepath" - "strconv" "github.com/Snowflake-Labs/sansshell/proxy/proxy" pb "github.com/Snowflake-Labs/sansshell/services/localfile" @@ -578,11 +577,3 @@ func ListRemote(ctx context.Context, conn *proxy.Conn, listRequest ListRequest) } return ret, nil } - -const fileModeSizeInBits = 12 - -func ParseFileMode(modeStr string) (uint16, error) { - mode, err := strconv.ParseUint(modeStr, 8, fileModeSizeInBits) - - return uint16(mode), err -}