mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
sftpd: add support for upload resume
we support resume only if the client sets the correct offset while resuming the upload. Based on the specs the offset is optional for resume, but all the tested clients sets a right offset. If an invalid offset is given we interrupt the transfer with the error "Invalid write offset ..." See https://github.com/pkg/sftp/issues/295 This commit add a new upload mode: "atomic with resume support", this acts as atomic but if there is an upload error the temporary file is renamed to the requested path and not deleted, this way a client can reconnect and resume the upload
This commit is contained in:
@@ -37,6 +37,12 @@ const (
|
||||
protocolSCP = "SCP"
|
||||
)
|
||||
|
||||
const (
|
||||
uploadModeStandard = iota
|
||||
uploadModeAtomic
|
||||
uploadModeAtomicWithResume
|
||||
)
|
||||
|
||||
var (
|
||||
mutex sync.RWMutex
|
||||
openConnections map[string]Connection
|
||||
@@ -356,6 +362,10 @@ func updateConnectionActivity(id string) {
|
||||
}
|
||||
}
|
||||
|
||||
func isAtomicUploadEnabled() bool {
|
||||
return uploadMode == uploadModeAtomic || uploadMode == uploadModeAtomicWithResume
|
||||
}
|
||||
|
||||
func executeAction(operation string, username string, path string, target string) error {
|
||||
if !utils.IsStringInSlice(operation, actions.ExecuteOn) {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user