mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
event action: add update modtime to fs rename
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -479,7 +479,7 @@ func (fs *SFTPFs) Create(name string, flag, _ int) (File, PipeWriter, func(), er
|
||||
}
|
||||
|
||||
// Rename renames (moves) source to target.
|
||||
func (fs *SFTPFs) Rename(source, target string) (int, int64, error) {
|
||||
func (fs *SFTPFs) Rename(source, target string, checks int) (int, int64, error) {
|
||||
if source == target {
|
||||
return -1, -1, nil
|
||||
}
|
||||
@@ -489,9 +489,15 @@ func (fs *SFTPFs) Rename(source, target string) (int, int64, error) {
|
||||
}
|
||||
if _, ok := client.HasExtension("posix-rename@openssh.com"); ok {
|
||||
err := client.PosixRename(source, target)
|
||||
if checks&CheckUpdateModTime != 0 && err == nil {
|
||||
fs.Chtimes(target, time.Now(), time.Now(), false) //nolint:errcheck
|
||||
}
|
||||
return -1, -1, err
|
||||
}
|
||||
err = client.Rename(source, target)
|
||||
if checks&CheckUpdateModTime != 0 && err == nil {
|
||||
fs.Chtimes(target, time.Now(), time.Now(), false) //nolint:errcheck
|
||||
}
|
||||
return -1, -1, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user