Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion get_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
type GitGetter struct {
Detectors []Detector

// Timeout sets a deadline which all hg CLI operations should
// Timeout sets a deadline which all git CLI operations should
// complete within. Defaults to zero which means no timeout.
Timeout time.Duration
}
Expand Down
18 changes: 16 additions & 2 deletions get_smbclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ import (
"regexp"
"strings"
"syscall"
"time"
)

// SmbClientGetter is a Getter implementation that will download a module from
// a shared folder using smbclient cli.
type SmbClientGetter struct{}
type SmbClientGetter struct {

// Timeout sets a deadline which all smb client CLI operations should
// complete within. Defaults to zero which means no timeout.
Timeout time.Duration
}

func (g *SmbClientGetter) Mode(ctx context.Context, u *url.URL) (Mode, error) {
if u.Host == "" || u.Path == "" {
Expand Down Expand Up @@ -254,7 +260,15 @@ func (g *SmbClientGetter) isDirectory(args []string, object string) (bool, error
}

func (g *SmbClientGetter) runSmbClientCommand(dst string, args []string) (string, error) {
cmd := exec.Command("smbclient", args...)
ctx := context.Background()

if g.Timeout > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(context.Background(), g.Timeout)
defer cancel()
}

cmd := exec.CommandContext(ctx, "smbclient", args...)

if dst != "" {
cmd.Dir = dst
Expand Down