mirror of
https://github.com/octoleo/restic.git
synced 2024-11-05 04:47:51 +00:00
Merge pull request #593 from restic/correct-backend-errors
local/sftp: Fix broken error handling
This commit is contained in:
commit
d097d40237
@ -176,6 +176,9 @@ func (b *Local) Save(h backend.Handle, p []byte) (err error) {
|
|||||||
|
|
||||||
tmpfile, err := writeToTempfile(filepath.Join(b.p, backend.Paths.Temp), p)
|
tmpfile, err := writeToTempfile(filepath.Join(b.p, backend.Paths.Temp), p)
|
||||||
debug.Log("local.Save", "saved %v (%d bytes) to %v", h, len(p), tmpfile)
|
debug.Log("local.Save", "saved %v (%d bytes) to %v", h, len(p), tmpfile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
filename := filename(b.p, h.Type, h.Name)
|
filename := filename(b.p, h.Type, h.Name)
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@ -44,22 +43,22 @@ func startClient(program string, args ...string) (*SFTP, error) {
|
|||||||
// get stdin and stdout
|
// get stdin and stdout
|
||||||
wr, err := cmd.StdinPipe()
|
wr, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
rd, err := cmd.StdoutPipe()
|
rd, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the process
|
// start the process
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the SFTP session
|
// open the SFTP session
|
||||||
client, err := sftp.NewClientPipe(rd, wr)
|
client, err := sftp.NewClientPipe(rd, wr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &SFTP{c: client, cmd: cmd}, nil
|
return &SFTP{c: client, cmd: cmd}, nil
|
||||||
@ -329,6 +328,10 @@ func (r *SFTP) Save(h backend.Handle, p []byte) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename, tmpfile, err := r.tempFile()
|
filename, tmpfile, err := r.tempFile()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
debug.Log("sftp.Save", "save %v (%d bytes) to %v", h, len(p), filename)
|
debug.Log("sftp.Save", "save %v (%d bytes) to %v", h, len(p), filename)
|
||||||
|
|
||||||
n, err := tmpfile.Write(p)
|
n, err := tmpfile.Write(p)
|
||||||
|
Loading…
Reference in New Issue
Block a user