mirror of
https://github.com/rclone/rclone
synced 2024-12-22 13:03:02 +01:00
Update error checking on fmt.Fprint* after errcheck update
Now we need to check or ignore errors on fmt.Fprint* explicitly - previously errcheck just ignored them for us.
This commit is contained in:
parent
a38f8b87ce
commit
512f4b4487
@ -340,7 +340,7 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||
|
||||
// Ask for password if none was defined and we're allowed to
|
||||
if pass == "" && *sftpAskPassword {
|
||||
fmt.Fprint(os.Stderr, "Enter SFTP password: ")
|
||||
_, _ = fmt.Fprint(os.Stderr, "Enter SFTP password: ")
|
||||
clearpass := config.ReadPassword()
|
||||
sshConfig.Auth = append(sshConfig.Auth, ssh.Password(clearpass))
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func runRoot(cmd *cobra.Command, args []string) {
|
||||
resolveExitCode(nil)
|
||||
} else {
|
||||
_ = Root.Usage()
|
||||
fmt.Fprintf(os.Stderr, "Command not found.\n")
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Command not found.\n")
|
||||
resolveExitCode(errorCommandNotFound)
|
||||
}
|
||||
}
|
||||
@ -368,12 +368,12 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
|
||||
func CheckArgs(MinArgs, MaxArgs int, cmd *cobra.Command, args []string) {
|
||||
if len(args) < MinArgs {
|
||||
_ = cmd.Usage()
|
||||
fmt.Fprintf(os.Stderr, "Command %s needs %d arguments minimum\n", cmd.Name(), MinArgs)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Command %s needs %d arguments minimum\n", cmd.Name(), MinArgs)
|
||||
// os.Exit(1)
|
||||
resolveExitCode(errorNotEnoughArguments)
|
||||
} else if len(args) > MaxArgs {
|
||||
_ = cmd.Usage()
|
||||
fmt.Fprintf(os.Stderr, "Command %s needs %d arguments maximum\n", cmd.Name(), MaxArgs)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Command %s needs %d arguments maximum\n", cmd.Name(), MaxArgs)
|
||||
// os.Exit(1)
|
||||
resolveExitCode(errorTooManyArguents)
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ func Lsf(fsrc fs.Fs, out io.Writer) error {
|
||||
continue
|
||||
}
|
||||
}
|
||||
fmt.Fprintln(out, list.Format(entry))
|
||||
_, _ = fmt.Fprintln(out, list.Format(entry))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
@ -135,7 +135,7 @@ func Tree(fsrc fs.Fs, outFile io.Writer, opts *tree.Options) error {
|
||||
if !opts.DirsOnly {
|
||||
footer += fmt.Sprintf(", %d files", nf)
|
||||
}
|
||||
fmt.Fprintln(outFile, footer)
|
||||
_, _ = fmt.Fprintln(outFile, footer)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func (s *StatsInfo) String() string {
|
||||
speed = speed * 8
|
||||
}
|
||||
|
||||
fmt.Fprintf(buf, `
|
||||
_, _ = fmt.Fprintf(buf, `
|
||||
Transferred: %10s (%s)
|
||||
Errors: %10d
|
||||
Checks: %10d
|
||||
@ -80,10 +80,10 @@ Elapsed time: %10v
|
||||
s.mu.RUnlock()
|
||||
|
||||
if !s.checking.empty() {
|
||||
fmt.Fprintf(buf, "Checking:\n%s\n", s.checking)
|
||||
_, _ = fmt.Fprintf(buf, "Checking:\n%s\n", s.checking)
|
||||
}
|
||||
if !s.transferring.empty() {
|
||||
fmt.Fprintf(buf, "Transferring:\n%s\n", s.transferring)
|
||||
_, _ = fmt.Fprintf(buf, "Transferring:\n%s\n", s.transferring)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ func checkPassword(password string) (string, error) {
|
||||
trimmedPassword := strings.TrimSpace(password)
|
||||
// Warn user if password has leading+trailing whitespace
|
||||
if len(password) != len(trimmedPassword) {
|
||||
fmt.Fprintln(os.Stderr, "Your password contains leading/trailing whitespace - in previous versions of rclone this was stripped")
|
||||
_, _ = fmt.Fprintln(os.Stderr, "Your password contains leading/trailing whitespace - in previous versions of rclone this was stripped")
|
||||
}
|
||||
// Normalize to reduce weird variations.
|
||||
password = norm.NFKC.String(password)
|
||||
@ -287,15 +287,15 @@ func checkPassword(password string) (string, error) {
|
||||
|
||||
// GetPassword asks the user for a password with the prompt given.
|
||||
func GetPassword(prompt string) string {
|
||||
fmt.Fprintln(os.Stderr, prompt)
|
||||
_, _ = fmt.Fprintln(os.Stderr, prompt)
|
||||
for {
|
||||
fmt.Fprint(os.Stderr, "password:")
|
||||
_, _ = fmt.Fprint(os.Stderr, "password:")
|
||||
password := ReadPassword()
|
||||
password, err := checkPassword(password)
|
||||
if err == nil {
|
||||
return password
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Bad password: %v\n", err)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Bad password: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ func getConfigPassword(q string) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "Error:", err)
|
||||
_, _ = fmt.Fprintln(os.Stderr, "Error:", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,9 +382,9 @@ func saveConfig() error {
|
||||
return errors.Errorf("Failed to write temp config file: %v", err)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintln(f, "# Encrypted rclone configuration File")
|
||||
fmt.Fprintln(f, "")
|
||||
fmt.Fprintln(f, "RCLONE_ENCRYPT_V0:")
|
||||
_, _ = fmt.Fprintln(f, "# Encrypted rclone configuration File")
|
||||
_, _ = fmt.Fprintln(f, "")
|
||||
_, _ = fmt.Fprintln(f, "RCLONE_ENCRYPT_V0:")
|
||||
|
||||
// Generate new nonce and write it to the start of the ciphertext
|
||||
var nonce [24]byte
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
// ReadPassword reads a password without echoing it to the terminal.
|
||||
func ReadPassword() string {
|
||||
line, err := terminal.ReadPassword(int(os.Stdin.Fd()))
|
||||
fmt.Fprintln(os.Stderr)
|
||||
_, _ = fmt.Fprintln(os.Stderr)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read password: %v", err)
|
||||
}
|
||||
|
@ -337,13 +337,13 @@ func (dt DirTree) Prune(dirNames map[string]bool) error {
|
||||
func (dt DirTree) String() string {
|
||||
out := new(bytes.Buffer)
|
||||
for _, dir := range dt.Dirs() {
|
||||
fmt.Fprintf(out, "%s/\n", dir)
|
||||
_, _ = fmt.Fprintf(out, "%s/\n", dir)
|
||||
for _, entry := range dt[dir] {
|
||||
flag := ""
|
||||
if _, ok := entry.(fs.Directory); ok {
|
||||
flag = "/"
|
||||
}
|
||||
fmt.Fprintf(out, " %s%s\n", path.Base(entry.Remote()), flag)
|
||||
_, _ = fmt.Fprintf(out, " %s%s\n", path.Base(entry.Remote()), flag)
|
||||
}
|
||||
}
|
||||
return out.String()
|
||||
|
@ -432,19 +432,19 @@ func (s *authServer) Start() {
|
||||
state := req.FormValue("state")
|
||||
if state != s.state {
|
||||
fs.Debugf(nil, "State did not match: want %q got %q", s.state, state)
|
||||
fmt.Fprintf(w, "<h1>Failure</h1>\n<p>Auth state doesn't match</p>")
|
||||
_, _ = fmt.Fprintf(w, "<h1>Failure</h1>\n<p>Auth state doesn't match</p>")
|
||||
} else {
|
||||
fs.Debugf(nil, "Successfully got code")
|
||||
if s.code != nil {
|
||||
fmt.Fprintf(w, "<h1>Success</h1>\n<p>Go back to rclone to continue</p>")
|
||||
_, _ = fmt.Fprintf(w, "<h1>Success</h1>\n<p>Go back to rclone to continue</p>")
|
||||
} else {
|
||||
fmt.Fprintf(w, "<h1>Success</h1>\n<p>Cut and paste this code into rclone: <code>%s</code></p>", code)
|
||||
_, _ = fmt.Fprintf(w, "<h1>Success</h1>\n<p>Cut and paste this code into rclone: <code>%s</code></p>", code)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fs.Debugf(nil, "No code found on request")
|
||||
w.WriteHeader(500)
|
||||
fmt.Fprintf(w, "<h1>Failed!</h1>\nNo code found returned by remote server.")
|
||||
_, _ = fmt.Fprintf(w, "<h1>Failed!</h1>\nNo code found returned by remote server.")
|
||||
}
|
||||
if s.code != nil {
|
||||
s.code <- code
|
||||
|
Loading…
Reference in New Issue
Block a user