sftpfs: improve rename and remove

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2022-02-16 17:08:22 +01:00
parent 6d3ff5a8ad
commit 4ed6e96c7b
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
4 changed files with 9 additions and 3 deletions

View file

@ -16,7 +16,7 @@ jobs:
upload-coverage: [true] upload-coverage: [true]
include: include:
- go: 1.17 - go: 1.17
os: windows-latest os: windows-2019
upload-coverage: false upload-coverage: false
steps: steps:

View file

@ -23,7 +23,7 @@ info:
SFTPGo also supports virtual folders, a virtual folder can use any of the supported storage backends. So you can have, for example, an S3 user that exposes a GCS bucket (or part of it) on a specified path and an encrypted local filesystem on another one. SFTPGo also supports virtual folders, a virtual folder can use any of the supported storage backends. So you can have, for example, an S3 user that exposes a GCS bucket (or part of it) on a specified path and an encrypted local filesystem on another one.
Virtual folders can be private or shared among multiple users, for shared virtual folders you can define different quota limits for each user. Virtual folders can be private or shared among multiple users, for shared virtual folders you can define different quota limits for each user.
SFTPGo allows to create HTTP/S links to externally share files and folders securely, by setting limits to the number of downloads/uploads, protecting the share with a password, limiting access by source IP address, setting an automatic expiration date. SFTPGo allows to create HTTP/S links to externally share files and folders securely, by setting limits to the number of downloads/uploads, protecting the share with a password, limiting access by source IP address, setting an automatic expiration date.
version: 2.2.2 version: 2.2.2-dev
contact: contact:
name: API support name: API support
url: 'https://github.com/drakkan/sftpgo' url: 'https://github.com/drakkan/sftpgo'

View file

@ -2,7 +2,7 @@ package version
import "strings" import "strings"
const version = "2.2.2" const version = "2.2.2-dev"
var ( var (
commit = "" commit = ""

View file

@ -324,6 +324,9 @@ func (fs *SFTPFs) Rename(source, target string) error {
if err := fs.checkConnection(); err != nil { if err := fs.checkConnection(); err != nil {
return err return err
} }
if _, ok := fs.sftpClient.HasExtension("posix-rename@openssh.com"); ok {
return fs.sftpClient.PosixRename(source, target)
}
return fs.sftpClient.Rename(source, target) return fs.sftpClient.Rename(source, target)
} }
@ -332,6 +335,9 @@ func (fs *SFTPFs) Remove(name string, isDir bool) error {
if err := fs.checkConnection(); err != nil { if err := fs.checkConnection(); err != nil {
return err return err
} }
if isDir {
return fs.sftpClient.RemoveDirectory(name)
}
return fs.sftpClient.Remove(name) return fs.sftpClient.Remove(name)
} }