mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 14:17:42 +00:00
sftp ReadDir: add path to return error messages (gh-1323)
fix missing "Close" string in debug log fmt
This commit is contained in:
parent
53a554c89d
commit
d8938e259a
@ -146,7 +146,7 @@ func (r *SFTP) checkDataSubdirs() error {
|
|||||||
datadir := r.Dirname(restic.Handle{Type: restic.DataFile})
|
datadir := r.Dirname(restic.Handle{Type: restic.DataFile})
|
||||||
|
|
||||||
// check if all paths for data/ exist
|
// check if all paths for data/ exist
|
||||||
entries, err := r.c.ReadDir(datadir)
|
entries, err := r.ReadDir(datadir)
|
||||||
if r.IsNotExist(err) {
|
if r.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -193,7 +193,12 @@ func (r *SFTP) Join(p ...string) string {
|
|||||||
|
|
||||||
// ReadDir returns the entries for a directory.
|
// ReadDir returns the entries for a directory.
|
||||||
func (r *SFTP) ReadDir(dir string) ([]os.FileInfo, error) {
|
func (r *SFTP) ReadDir(dir string) ([]os.FileInfo, error) {
|
||||||
return r.c.ReadDir(dir)
|
fi, err := r.c.ReadDir(dir)
|
||||||
|
|
||||||
|
// sftp client does not specify dir name on error, so add it here
|
||||||
|
err = errors.Wrapf(err, "(%v)", dir)
|
||||||
|
|
||||||
|
return fi, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNotExist returns true if the error is caused by a not existing file.
|
// IsNotExist returns true if the error is caused by a not existing file.
|
||||||
@ -476,7 +481,7 @@ var closeTimeout = 2 * time.Second
|
|||||||
|
|
||||||
// Close closes the sftp connection and terminates the underlying command.
|
// Close closes the sftp connection and terminates the underlying command.
|
||||||
func (r *SFTP) Close() error {
|
func (r *SFTP) Close() error {
|
||||||
debug.Log("")
|
debug.Log("Close")
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -501,7 +506,7 @@ func (r *SFTP) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *SFTP) deleteRecursive(name string) error {
|
func (r *SFTP) deleteRecursive(name string) error {
|
||||||
entries, err := r.c.ReadDir(name)
|
entries, err := r.ReadDir(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "ReadDir")
|
return errors.Wrap(err, "ReadDir")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user