mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 08:23:47 +01:00
sftp: fix NewObject with leading /
This was breaking the use of operations/stat with remote with an initial / See: https://forum.rclone.org/t/rclone-rc-api-operations-stat-is-not-working-for-sftp-remotes/34560
This commit is contained in:
parent
5db4493557
commit
7edb4c0162
@ -1775,11 +1775,14 @@ func (o *Object) setMetadata(info os.FileInfo) {
|
|||||||
|
|
||||||
// statRemote stats the file or directory at the remote given
|
// statRemote stats the file or directory at the remote given
|
||||||
func (f *Fs) stat(ctx context.Context, remote string) (info os.FileInfo, err error) {
|
func (f *Fs) stat(ctx context.Context, remote string) (info os.FileInfo, err error) {
|
||||||
|
absPath := remote
|
||||||
|
if !strings.HasPrefix(remote, "/") {
|
||||||
|
absPath = path.Join(f.absRoot, remote)
|
||||||
|
}
|
||||||
c, err := f.getSftpConnection(ctx)
|
c, err := f.getSftpConnection(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("stat: %w", err)
|
return nil, fmt.Errorf("stat: %w", err)
|
||||||
}
|
}
|
||||||
absPath := path.Join(f.absRoot, remote)
|
|
||||||
info, err = c.sftpClient.Stat(absPath)
|
info, err = c.sftpClient.Stat(absPath)
|
||||||
f.putSftpConnection(&c, err)
|
f.putSftpConnection(&c, err)
|
||||||
return info, err
|
return info, err
|
||||||
|
Loading…
Reference in New Issue
Block a user